简体   繁体   English

Visual Studio 2010(C#):乘以*之前和之后为空白

[英]Visual Studio 2010 (C#): Blank before and after * when multiplying

I noticed a strange behavior in Visual Studio 2010 when programming C#. 在编程C#时,我注意到Visual Studio 2010中有一个奇怪的行为。 When I type 当我打字

var x = 2 * 5

and then enter ';' 然后输入“;” VS changes the line to VS将行更改为

var x = 2*5;

So it removes the blanks. 因此,它消除了空白。 On the other hand, if I do CTRL+X and CTRL+V in that line, the blanks are inserted again; 另一方面,如果我在那一行中按CTRL + X和CTRL + V,则将再次插入空格。

var x = 2 * 5;

This is quite annoying when using tools like SVN, since it makes tracking actual changes in the code more difficult. 使用SVN之类的工具时,这很烦人,因为它使跟踪代码中的实际更改更加困难。 I looked at 我看着

Tools->Options->Text Editor->C#->Formatting->Spacing 工具->选项->文本编辑器-> C#->格式->间距

but couldn't find anything suitable. 但找不到合适的东西。 Does anybody of you know how to unify the behavior? 你们中有人知道如何统一行为吗?

Thanks, 谢谢,

Hendrik 亨德里克

In the Menu: 在菜单中:

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

Go to Set spacing for operators and select Insert space before and after binary operators 转到Set spacing for operators然后选择Insert space before and after binary operators

在此处输入图片说明

Also in case you use extensions like ReSharper , make sure they are configured the same way as Visual Studio itself. 同样,如果您使用ReSharper之类的扩展,请确保以与Visual Studio本身相同的方式配置它们。

在此处输入图片说明

This is a german version... but in english: 这是德语版本...但是用英语:

Tools->Options->Text Editor->C#->Formatting->Spacing 工具->选项->文本编辑器-> C#->格式->间距

and set the first option for "Set spacing for operators". 并为“设置运算符的间距”设置第一个选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM