Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

[vim] Delete blank lines

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:

:g/^$/d

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

:g/^s*$/d

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

:g/^_$n_^$/d

Reference: Stack Overflow.



This post first appeared on A Walk In The Rain | My Life And My Thoughts, please read the originial post: here

Share the post

[vim] Delete blank lines

×

Subscribe to A Walk In The Rain | My Life And My Thoughts

Get updates delivered right to your inbox!

Thank you for your subscription

×