You can delete all blank lines in a file with the following command: :g/^$/d
This command is explained as follows:
:g is a global command that should occur on the entire file/ start of the search pattern^g/end of the search patternd deletes a line