![cli](https://skayal.com/wp-content/uploads/2020/05/kisspng-computer-icons-command-line-interface-linux-system-command-line-icon-vector-5ab10e74cf4276.197344361521553012849.png)
03
Mar
[vim] Delete blank lines
Comments
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.