Visual Studio 2017 可以像 Vs2010 一样删除 = 周围的空间吗?

问题描述:

我设置 Visual Studio 以删除 C# 代码中的所有空格,以及声明/赋值周围的空格.

I setup Visual Studio to remove all spaces in C# code, also around declarations/assignments.

我想要

int x = 5;

像这样自动格式化

int x=5;

在 Visual Studio 2010 中,这可以正常工作,忽略声明语句中的空格"选项已关闭.在 Visual Studio 2017 中,根据我的设置删除了许多空格,例如围绕+"或,",但不是赋值.我可以启用忽略声明语句中的空格",那么至少它不会在触发自动格式化时插入空格,但我希望它自动删除它们.这是对 Vs2010 的回归吗?

In Visual Studio 2010 this works fine, the "Ignore spaces in declaration statements" option is off. In Visual Studio 2017 many spaces are removed per my settings, e.g. around "+" or ",", but not assignments. I can enable "Ignore spaces in declaration statements", then at least it will not insert the spacing upon triggering autoformat, but I would like it to automatically remove them. Is this a regression to Vs2010?

我已取消选中所有用于插入空格的复选框并选择删除二元运算符前后的间距"

I have unchecked all checkboxes for inserting spaces and chosen "Remove spacing before and after binary operators"

Visual Studio 2013 也会出现同样的问题

The same issue happens with Visual Studio 2013

您应该查看工具 --> 选项 --> 文本编辑器 --> C# --> 格式 --> 间距,然后更改为运算符设置间距".

You should look in Tools --> Options --> Text Editor --> C# --> Formatting --> Spacing and then change the option under "Set Spacing for Operators".