Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

with grep I can do a grep -v "my search" to get all the lines with out "my search"

with sed I can sed '/baz/!s/foo/bar/g' to find replace text on lines with out baz

Is there a way to do the same thing vim. And is it possible but with out the "s///" syntax. Using just the "/" search syntax.

share|improve this question
up vote 18 down vote accepted

matches all the lines were pattern is found.


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


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

Contrived examples, yes.

share|improve this answer
I lol'd on "nrettap". – UncleZeiv Jan 30 '12 at 14:44

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



share|improve this answer
I did not know about the \@ directive that lets you reference the previous atom in search. Very useful. – nelaar Jan 30 '12 at 14:19
Even if correct, this is really costly. – Benoit Jan 30 '12 at 17:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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