阻止Visual Studio 2013自动删除分配中的额外空格

时间:2015-03-03 14:44:49

标签: c# visual-studio visual-studio-2013 code-formatting

我尝试对齐某些分配以提高可读性,但每次粘贴内容时,Visual Studio 2013会自动删除=之前的额外空格。

例如,这个:

static class Constants {
    public static string Something      = "A value";
    public static string SomethingElse  = "Another value";
}

重新格式化如下:

static class Constants {
    public static string Something = "A value";
    public static string SomethingElse = "Another value";
}

有没有办法将其关闭?

2 个答案:

答案 0 :(得分:8)

可以在Tools->Options->Text Editor->C#->Formatting->Spacing中通过"忽略声明中的空格"来关闭它。选项。

enter image description here

答案 1 :(得分:3)

VB.net for VisualStudio 2016 instructions:

|<-- main menu bar -->|<------------Side Panel Of Options Window------>|
Tools --> Options --> | Text Editor v | --> | Basic v | --> | Advanced |

    Options.Advanced window:
 =========================================================  
 =   +----Highlighting-------------------------------+   =
 =   | (...)                                         |   =
 =   +-----------------------------------------------+   =
 =                                                       =
 =   +----Outlining----------------------------------+   =
 =   | (...)                                         |   =
 =   +-----------------------------------------------+   =
 =                                                       =
 =   +----Editor Help--------------------------------+   =
 =   |                                               |   =
 =   | [ ] Pretty listing (reformatting) of code     |   =
 =   |                                               |   =
 =   +-----------------------------------------------+   =
 =========================================================

截屏: enter image description here