在 Visual Studio 2012 中,我创建了一个宏来创建一个左大括号,创建一个新行,创建一个新行,创建右大括号并将光标向上移动一行,然后是一个 TAB。
该宏与 Ctrl + 0 关联,因此在 Ctrl + 0 之后我准备好写代码。
如何在没有我的宏的 Visual Studio 2012 中做同样的事情?
最佳答案
这是我添加到向导中创建的 prj:在 VS2012 中安装它并关联组合键:SHIFT+ALT+0
public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
handled = false;
if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if(commandName == "CurlyBraces.Connect.CurlyBraces")
{
if (_applicationObject.ActiveDocument != null)
{
TextSelection objSel = (EnvDTE.TextSelection)(_applicationObject.ActiveDocument.Selection);
objSel.NewLine();
objSel.Insert("{"); objSel.Indent();
objSel.NewLine();
objSel.NewLine();
objSel.Insert("}"); objSel.Indent();
objSel.LineUp();
objSel.Indent();
objSel.SmartFormat();
objSel.LineUp();
}
}
}
}
关于c# - Visual Studio 2012 - 如何自动打开关闭花括号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17250999/