Zet - How do I delete all lines in vim that don’t match a pattern?

How do I delete all lines in vim that don’t match a pattern?

You can use

:g!/price/d

to delete every line that doesn’t contain “price”

As answered below, g! is an alias to v. this is equivalent to

:v/price/d

See https://superuser.com/questions/265085/how-to-delete-all-lines-that-do-not-contain-a-certain-word-in-vim

#vim