One Command, Every Line with :g

The shape

:g/pattern/command

Run command on every line matching pattern. :v/pattern/command (or :g!) runs it on every line that does not match.

The common ones

: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

With normal-mode commands

: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.

Why it beats a macro

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.