Remove empty lines in VIM editor

This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.


VIM is a powerful editor and used by many geeks across the world. Often, you many want to remove blank lines from your code.

Following is the way to do it:

a. Open vim.
b. Click on 'Escape'
b. Type in the following code:

:%s/^[\ \t]*\n//g 

Done. All your empty or blank lines should be gone now.





Post Comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.