Search code examples
c#visual-studioautoformatting

Is there a Possibility to Configure Visual Studio Formatting to ignore whitespaces around variable assignments


I have variables Assigned like this, so all assignment operators are in line.

var filterSets      = ...;
var names           = ...;
var filter          = ...;

when Visual Studio formatted it. (for Example when reapplying the last })

var filterSets = ...;
var names = ...;
var filter = ...;

Whats also applying a change for those 3 lines;

I searched a while and didn't find a way to configure the Formatting to ignore those whitespaces.

I wouldn't really care if it wouldn't show as changes in version Control...


Solution

  • You don't mention which VS version you are using, however, in VS 2017 you can find this in Tools/Options, under Text Editor/C#/Code Style/Formatting/Spacing.

    The option is called "Ignore spaces in declaration statements"

    enter image description here