Sunday, February 13, 2011

Vim Usage: remove all empty lines

In text editing, especially when you copied the content from some website, you might want to delete all empty lines in your text. In the past, I will do something stupid which is to delete the empty line one by one. It takes time and I use this command to achieve my goal
dd, (go to next empty line), then "." ,until you delete all the empty line.

Explanation:
  • dd - delete whole line
  • . - repeat the last command (I like this one, very useful)
However, I realized there is a command which is much more useful and handy:

:g/^$/d
Feel free to use it if you need to delete all empty lines :-) 

No comments:

Post a Comment