Nov 7, 2018

How to delete blank lines using Vim or sed

For Vim
:g/^$/d

:g will execute a command on lines which match a regex.
the delete command is :d

For sed:

sed '/^$/d'

the regex is 'blank line'. If you have space/tabs in your "empty" line, you need to change to use: ^\s*$