[vim] Delete blank lines

26 Aug

Here are two ways to delete the blank lines in a text file opened with vim:

1. Delete all the blank lines with NO white spaces other than new lines:


2. Delete the blank lines containing any type of white spaces:


BONUS: Remove only multi blank lines (reduce them to a single blank line) and leaving single blank lines intact:


Reference: Stack Overflow.

About these ads
1 Comment

Posted by on August 26, 2013 in vim


Tags: , , , , , , ,

One response to “[vim] Delete blank lines

  1. albin thomas

    July 22, 2014 at 3:48 AM

    loved this


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 35 other followers

%d bloggers like this: