Thursday, December 19, 2013

Removing Blank Lines

Here's a handy one-liner to remove blank lines from a file.
:g/^$/d
Breaking this down. The "g" will execute a command on lines that match a regular expression. The regular expression matches blank lines, and the command is "d" (delete).

1 comment:

Anonymous said...

I use this opposite approach so that the pattern is a bit simpler to type:

:v/./d