You can enable whitespace trimming at file save time from settings:
- Open Visual Studio Code User Settings (menu File → Preferences → Settings → User Settings tab).
- Click the
icon in the top-right part of the window. This will open a document.
- Add a new
"files.trimTrailingWhitespace": true
setting to the User Settings document if it’s not already there. This is so you aren’t editing the Default Setting directly, but instead adding to it. - Save the User Settings file.
We also added a new command to trigger this manually (Trim Trailing Whitespace from the command palette).