Robert Fraser Robert Fraser - 1 year ago 183
C# Question

Visual Studio : Automatically insert a space after typing if(

We have a code style checker that's run before every check-in that requires that C# if statements be formatted like:

if (condition)

However, my muscle memory has already developed for typing:


Is there any way to get Visual Studio 2010 to automatically insert that space if I type the if without it? I know you can set it that when you paste code, it will automatically do this, but not while typing. Thanks!

Answer Source

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

Then check/tick Insert space after keywords in control flow statements, which is listed under the Set other spacing options sub group.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download