[vim] Show and delete all lines that contain a certain pattern

04 Nov

1. Show all the lines that match a pattern, say PATTERN

Use “g!” or “v” for negative matching. For example, to show all the lines that DO NOT match the pattern, PATTERN, use

2. Delete all the lines that contain the pattern, PATTERN

Again, g! or v may be used for negative matching.

Application: You may use any of the following two commands to delete all the blank lines (including lines containing only whitespaces) from a file

Reference: Vim Wiki.

About these ads
Leave a comment

Posted by on November 4, 2012 in vim


Tags: , , , , , ,

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: