Visual Studio:键入后自动插入空格if(

Rob*_*ser 12 c# coding-style code-formatting visual-studio-2010 visual-studio

我们有一个代码样式检查器,它在每次签入之前运行,要求C#if语句的格式如下:

if (condition)
Run Code Online (Sandbox Code Playgroud)

但是,我的肌肉记忆已经开发用于打字:

if(condition)
Run Code Online (Sandbox Code Playgroud)

有没有办法让Visual Studio 2010自动插入该空间,如果我输入if而没有它?我知道你可以设置它,当你粘贴代码时,它会自动执行此操作,但不会在键入时.谢谢!

dot*_*emy 25

Tools> Options> Text Editor> C#> Formatting>Spacing

然后检查/勾选子组Insert space after keywords in control flow statements下面列出的内容Set other spacing options.

赢得.


cap*_*aig 5

Resharper将使用其默认格式设置执行此操作.Ctrl + K + D将格式化整个文档.多数民众赞成我是如何做到的.看起来VS的格式化选项可能能够帮助你,但我从来没有玩过足够的.

Resharper完全值得为此以及其他许多原因.