how to do a vim search inverse search for all lines with out text

:g/pattern/

matches all the lines were pattern is found.

:v/pattern/

does the opposite. See :h global for more details.

You can use it like this:

:v/pattern/norm Ipattern not found - <CR>

to prepend "pattern not found - " to every line that doesn't have "pattern" or

:v/pattern/s/nrettap/pattern

to replace "nrettap" with "pattern" on every line that doesn't have "pattern".

Contrived examples, yes.


To search for the lines not containing foo, for example, do:

/^\(\(.*foo.*\)\@!.\)*$

Source: http://vim.wikia.com/wiki/Search_for_lines_not_containing_pattern_and_other_helpful_searches