So once you know how to find and replace text in vim, you can easily replace trailing whitespace on lines of code with the following:
| |
:– issue VIM command%– the buffer in the current windows– substitute\s– regex for whitespace\+– regex for one or more$– found at the end of the search result//– the text to replace the whitespace with – nothingg– replace every instance found
Done. If you’d like to remove all whitespace upon file save (:w) then add the following to your .vimrc
| |
:)