Remove Empty Lines and Comments with vi

Remove all lines that start with #

:g/^#/d

Remove all empty lines, assumes no spaces or tabs:

:g/^$/d

http://help.metaltoad.com/unix-commandline/vi-tricks/remove-empty-lines-and-comments-with-vi.html