Thingy Ma Jig is the blog of Nicholas Thompson and contains any useful tips, sites and general blog-stuff which are considered interesting or handy!
Posted on 16 July 2008 in
vim
linux
Drupal
After recently reading about how great VIM is for the three hundredth and fifty second time (I kept count), I decided to take a look.
It really is quite cool! I've also decided to try to log any cool tips I learn about it. Here is the first which I found after running the coder module on one of my modules (Page Title 2) and it threw hundreds of errors about too many trailing spaces on empty lines.
[adsense:468x60:4496506397]
After a bit of googling, it turned out to be REALLY easy!
:%s=\s\+$==
And thats it!
%
tells it to be global - not just the current line.S
is a shortcut for substitute
.\s
(whitespace) and \+
(at least once) are regular expression terms (the + needs to be escaped, it seems…).$
(dollar) represents the end of a line.=
are being used as delimiters, the ==
at the end implies that the pattern is replaced with nothing.