简体   繁体   中英

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

I noticed a strange behavior in Visual Studio 2010 when programming C#. When I type

var x = 2 * 5

and then enter ';' VS changes the line to

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;

var x = 2 * 5;

This is quite annoying when using tools like SVN, since it makes tracking actual changes in the code more difficult. I looked at

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

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

Go to Set spacing for operators and select 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.

在此处输入图片说明

This is a german version... but in english:

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

and set the first option for "Set spacing for operators".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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