Tuesday, January 14, 2014

Removing Lines that Don't Match a Pattern

Following up on a previous tip, you can also use the "g" and "d" commands to remove lines in your current buffer that don't match a specific pattern. The following example would remove all lines that don't match "www.example.com".
:g!/www\.example\.com/d

1 comment:

Anonymous said...

If I'm not mistaken, :v will function the same as :g! so
:v/www\.example\.com/d
should give the same result.