What command can I run to remove blank lines in Vim?
:g/^$/d
:g will execute a command on lines which match a regex. The regex is 'blank line' and the command is :d (delete)
Found it, it's:
g/^\s*$/d
Source: Power of g at vim wikia
Brief explanation of
:g:[range]g/pattern/cmdThis acts on the specified [range] (default whole file), by executing the Ex command cmd for each line matching pattern (an Ex command is one starting with a colon such as
:dfor delete). Before executing cmd, "." is set to the current line.
The following can be used to remove only multi blank lines (reduce them to a single blank line) and leaving single blank lines intact:
:g/^\_$\n\_^$/d