Removing trailing whitespace with VIM regular expressions

Feb 4 2012

While cleaning up old sourcecode that I wrote with TextMate, I'm finding many cases where TextMate left trailing whitespace. To keep with current coding conventions, I am removing these extra spaces.

Here's a quick way to do this in VIM:

:%s/\s\\+$//g

This tells VIM to search the entire document for lines that end with one or more whitespace characters. Any matching spaces will be removed. <!--break-->



comments powered by Disqus