This is a stupid question about a basic feature but I don't have yet
enough knowledge with vim.
How can I delete all lines of a buffer where at least one instance of
"foobar" is found ?
eg the output of:
grep -v file.txt "foobar"
You'll want the ":g" command:
:g/foobar/d
It's inverse (delete lines that *don't* match "foobar") is
:v/foobar/d
or
:g!/foobar/d
You can use any Ex command...you're not limited to "[d]elete".
Thus, you can indent all lines matching a pattern:
:g/foobar/>
or only change "blah" to "baz" on lines containing "foobar":
:g/foobar/s/blah/baz/g
or even operate on ranges of lines found by the :g/:v commands:
:g/foobar/.,+3 fold
will fold all lines containing "foobar" and the following three
lines.
You can read more than anybody should ever have to know at
:help :g
:help ex-cmd-index
:help range
HTH,
-tim