In the buffer
Before:
2026-09-15 10:02 INFO worker started
^
2026-09-15 10:04 DEBUG cache warm, 812 keys
2026-09-15 10:07 ERROR upload failed: timeout
2026-09-15 10:09 INFO retry scheduled
2026-09-15 10:11 ERROR upload failed: timeout
2026-09-15 10:15 INFO worker idle
After typing :v/ERROR/d:
2026-09-15 10:07 ERROR upload failed: timeout
2026-09-15 10:11 ERROR upload failed: timeout
^
Six lines in, two lines out, with the cursor left at the bottom of what remains.
When you would reach for it
You pasted a log, a test report, or a long config dump into a buffer and only a handful of lines matter. Scrolling and deleting by hand works until the file is four hundred lines long, at which point you start missing lines. :v inverts the question: instead of hunting for what to remove, you describe what to keep and vim discards everything else. It is the fastest way to turn a wall of output into the six lines you were actually reading it for.
Gotchas
- If the pattern matches nothing,
:vmarks every line and you get an empty buffer. This is consistent behavior, not a failure, so vim reports no error. Pressuonce and the whole thing comes back, because the entire global command is a single undo block. - The pattern is case sensitive unless
'ignorecase'is set.:v/error/dagainst a buffer of uppercaseERRORlines deletes all of it. Test the pattern with/first and count the matches before you run the deletion. :vhas no!form.:v!/pattern/dfails withE477: No ! allowed. The inverse of:vis plain:g, and:g!is the long spelling of:v.- Without a range,
:voperates on the whole file, not from the cursor down. Prefix a range to limit it::10,40v/pattern/d.
Variants
/ERROR
:v//d
An empty pattern reuses the last search, so you can search first, confirm the matches with n, then filter with five keystrokes.
:v/ERROR\|WARN/d
Alternation keeps more than one kind of line. In the log above this leaves the two ERROR lines and any WARN lines standing.
:g/^$/d
The same engine pointed the other way: mark every line matching “empty line” and delete those. :g and :v differ only in which lines get marked.