Here’s a quick tip on how to get rid of unwanted trailing whitespace using vim.
Let’s say, I have the following code:
Open that file with vim. The following command deletes any trailing white spaces.
Here’s the screenshot of the text after removing the whitespace:
\s finds whitespace (a space or tab).
\+ finds one or more occurrences.
$ matches the end of line, finally
e flag means no error is displayed.
- Remove unwanted spaces (warning: this reference page contains lots of ads, probably avoid opening it on a mobile device.)