As shown in the Remove all blank lines using Vim post :g command is what we are looking for.

For example, to remove all lines containing the string “TO REMOVE” we have to issue the following command:

:g/TO\ REMOVE/d

That`s all.