vim

vglobal: Execute commands on lines that do not match globally

Introduction#

:vglobal or :v is the opposite of :global or :g that operates on lines not matching the specified pattern (inverse).

:v/pattern/d

Example:

> cat example.txt
  TODO: complete this
  NOT this
  NOT that
  TODO: Complete that

Open the example.txt using vim and type :v/TODO/d in the Ex mode. This will delete all lines that do not contain the TODO pattern.

example.txt After deleting lines that don't match TODO


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow