In vim I can delete all lines that contain the word "price" with this

:g /price/d

How can I delete all lines that do NOT contain the word "price"?

link|improve this question

75% accept rate
feedback

1 Answer

up vote 7 down vote accepted

You can use

:%g!/price/d

to delete every line that doesn't contain "price"

link|improve this answer
I knew it would be easy... – digitaljoel Mar 31 '11 at 23:28
3  
:g! is also known as :v (akin to grep -v). – Chris Johnsen Apr 1 '11 at 3:17
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.