【问题标题】:Stop Visual Studio 2013 from automatically removing extra spaces in assignments阻止 Visual Studio 2013 自动删除作业中的多余空格
【发布时间】:2015-05-04 06:35:17
【问题描述】:

我正在尝试对齐一些作业以提高可读性,但每次我粘贴某些内容时,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";
}

有没有办法关闭它?

【问题讨论】:

  • 我不确定该功能,但您可以在粘贴后立即按 ctrl+z 以恢复原始格式。
  • @Matthew: 是的,我知道,但是每次都必须撤消很烦人......而且,我仍然希望能够格式化文档(ctrl-kctrl-d ) 没有所有对齐爆炸:)

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


【解决方案1】:

这可以通过“忽略声明语句中的空格”选项在Tools->Options->Text Editor->C#->Formatting->Spacing 中关闭。

【讨论】:

  • 没问题 :-) 似乎只有声明的选项,而不是一般的赋值。嗯嗯。
  • 是的,如果有更多“忽略”选项就好了。
  • 虽然这应该有效,但它似乎没有达到预期的效果,因为格式化文档仍会删除额外的空白和制表符
【解决方案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     |   =
 =   |                                               |   =
 =   +-----------------------------------------------+   =
 =========================================================

屏幕截图:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-02
    • 2017-07-24
    • 2015-01-19
    • 2016-05-19
    • 1970-01-01
    • 2023-01-16
    • 1970-01-01
    • 2010-09-10
    相关资源
    最近更新 更多