Title here
Summary here
:g/pattern/commandRun command on every line matching pattern. :v/pattern/command (or :g!) runs it on every line that does not match.
:g/TODO/d " delete every TODO line
:v/error/d " keep only lines mentioning error
:g/^$/d " delete blank lines
:g/import/m0 " move all imports to the top
:g/pattern/t$ " copy matching lines to the end:g/^/normal A; " append a semicolon to every line
:g/func/normal >> " indent every line containing func:g + normal is where it becomes genuinely powerful — any normal-mode edit, applied everywhere it matches.
A macro walks the file and can drift. :g finds every match first, then acts, so it does not matter where the cursor started or how the lines are spaced.