Short version: my company is enforcing a coding guideline rule that prevents code from being submitted that has trailing whitespace characters.
Is there a plugin for Visual Studio that removes trailing whitespaces whenever a file is saved?
Long version:
There are many good reasons to have trailing whitespace removed from source code:
- it takes more storage space than necessary
- when you hit the End key in some editors, the cursor does not go to the expected place
- everyone in with desktop publishing background hates duplicate spaces and trailing whitespace because it makes text break weird
- the compiler needs more time to compile
- some editors might apply a line wrap due to the additional character when it reaches the character limit
- it breaks
vim
- some programming languages like Python may fail to compile with whitespace in multiline strings
- TCL fails to compile with whitespace
- it may mess up the diff
Although some of the reasons could be avoided by technical means, I want to respect the coding guidelines. But still, I'm reluctant to scanning for whitespace with my eyes. It's so ... invisible.
The plugin must
- work in VS 2015 and later
- remove irrelevant trailing whitespace
- keep potentially relevant whitespace (e.g. in multiline strings)
Ideally (optional, but preferred):
- highlights irrelevant and potentially relevant whitespace in the editor while typing