Paolo Tedesco Paolo Tedesco - 2 months ago 11
C# Question

Stop Visual Studio 2013 from automatically removing extra spaces in assignments

I'm trying to align some assignments to improve readability, but each time I paste something, Visual Studio 2013 automatically removes the extra spaces before the

=
.

For example, this:

static class Constants {
public static string Something = "A value";
public static string SomethingElse = "Another value";
}


gets re-formatted like this:

static class Constants {
public static string Something = "A value";
public static string SomethingElse = "Another value";
}


Is there a way to turn this off?

Answer

This can be turned off in Tools->Options->Text Editor->C#->Formatting->Spacing via the "Ignore spaces in declaration statements" option.

enter image description here