Cheatsheet Pages / Vim Cheatsheet
How to act on every matching line in Vim — :g/pattern/d and :v
Every line mentioning TODO needs deleting — or every line NOT matching a pattern needs to go.
Almost every entry was run headless in Vim 9.1 and the resulting file checked; the few entries a tiny build cannot run (system clipboard, persistent undo, the sudo save) were verified against Vim's own documentation instead.
:g/TODO/d " delete EVERY line that matches TODO, in one command
:v/keep/d " :v is :g inverted — delete every line that does NOT match keep
Good to know
:g runs any Ex command on matching lines (:g/pattern/p prints them, :g/pattern/t$ copies them to the end); delete is just the most-used case.
