cli

[vim] Delete blank lines

Here are two ways to delete the blank lines in a text file opened with vim:

1. Delete all the blank lines with NO white spaces other than new lines:

:g/^$/d

2. Delete the blank lines containing any type of white spaces:

:g/^\s*$/d

BONUS: Remove only multi blank lines (reduce them to a single blank line) and leaving single blank lines intact:

:g/^\_$\n\_^$/d

Reference: Stack Overflow.