[ACCEPTED]-How can I trim trailing whitespace in Visual Studio 2012 on save?-visual-studio-2012

Accepted answer
Score: 40

There are at least two extensions that can 8 do this. One is CodeMaid which explicitly will trim 7 trailing blanks on save, and the other is 6 Productivity Power Tools which can run the Format Document automatically 5 on save.

To add an extension from within 4 Visual Studio 2012, select menu ToolsExtensions and Updates.... In 3 the window, select Online on the left and enter 2 your search string for CodeMaid or Productivity Power Tools in the box on 1 the upper right.

Score: 22

Ctrl + H
Find what:
Replace 3 with:
\s instead of [\u0020] delete 2 empty line feeds, probably because it matches 1 line feeds...

Score: 15

You can use Mads Kristensen's Trailing Whitespace Visualizer. It has a 7 keyboard shortcut to remove trailing whitespace 6 from the current file. Ctrl + K, Ctrl + \

Note: this 5 doesn't run on save. You have to explicitly 4 run the command. On the bright side, it 3 visually highlights the offending whitespace, so 2 it's easier to identify cleanup opportunities 1 even in code you haven't modified.

Score: 8

EditorConfig has an option for removing trailing whitespace, and 3 it has a Visual Studio extension. You'll 2 need to add trim_trailing_whitespace = true to your .editorconfig to make 1 it work.

More Related questions