Stop Visual Studio 2013 from automatically removing extra spaces in assignments

六月ゝ 毕业季﹏ 提交于 2019-12-01 18:57:28

问题


I'm trying to align some assignments to improve readability, but each time I paste something, Visual Studio 2013 automatically removes the extra spaces before the =.

For example, this:

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

gets re-formatted like this:

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

Is there a way to turn this off?


回答1:


This can be turned off in Tools->Options->Text Editor->C#->Formatting->Spacing via the "Ignore spaces in declaration statements" option.




回答2:


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     |   =
 =   |                                               |   =
 =   +-----------------------------------------------+   =
 =========================================================

Screen shot:



来源:https://stackoverflow.com/questions/28834688/stop-visual-studio-2013-from-automatically-removing-extra-spaces-in-assignments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!