我可以发誓,我见过人们打字函数头部,然后打一些组合键来自动创建功能括号并插入光标它们之间像这样:如何使Visual Studio自动生成功能块的大括号?
void foo()_
到
void foo()
{
_
}
是这是一个内置功能?
我可以发誓,我见过人们打字函数头部,然后打一些组合键来自动创建功能括号并插入光标它们之间像这样:如何使Visual Studio自动生成功能块的大括号?
void foo()_
到
void foo()
{
_
}
是这是一个内置功能?
退房Resharper - 它是一个Visual Studio插件,具有此功能以及许多其他开发帮助。请参阅C# Completer,另一个附加组件。
如果您想自己推出,请查看this article。疯狂的人应该必须这样做,但。
它可以通过使用代码段来实现,一些已经建成(尝试键入“SVM”击中TAB-TAB)..
有创造这些是一个丰富的信息对网:
有一个谷歌!我用它们很棒! :D
请看visual assist以及。
这些工具看起来不错(!特别是ReSharper的,但在$ 200-350哎哟),但我最终只是记录一个宏并将其分配给CTRL + ALT + [
宏观出来是这样的:
Sub FunctionBraces()
DTE.ActiveDocument.Selection.NewLine
DTE.ActiveDocument.Selection.Text = "{}"
DTE.ActiveDocument.Selection.CharLeft
DTE.ActiveDocument.Selection.NewLine(2)
DTE.ActiveDocument.Selection.LineUp
DTE.ActiveDocument.Selection.Indent
End Sub
编辑:我用宏记录器来做到这一点,并没有太坏
我刚刚创建了一个基于@卢克的上面。这一次,你要按下回车键,然后打你的组合键,它会插入:
if()
{
}
else
{
}
它将把光标放在括号由if语句。
Sub IfStatement()
DTE.ActiveDocument.Selection.Text = "if()"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "{"
DTE.ActiveDocument.Selection.NewLine(2)
DTE.ActiveDocument.Selection.Text = "}"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "else"
DTE.ActiveDocument.Selection.NewLine(2)
DTE.ActiveDocument.Selection.Text = "{"
DTE.ActiveDocument.Selection.NewLine(2)
DTE.ActiveDocument.Selection.Text = "}"
DTE.ActiveDocument.Selection.LineUp(False, 7)
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.CharLeft(3)
End Sub