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.
This post first appeared on A Walk In The Rain | My Life And My Thoughts, please read the originial post: here