Normal (:norm)

Run Normal-mode keystrokes from Ex.

Keys: :norm

:norm runs a sequence of Normal-mode keystrokes on each line in a range. Combine with :g for surgical bulk edits โ€” anything you can do with keys, you can do over thousands of lines.

Normal

:norm (or :normal) runs a string of Normal-mode keys on every line in the range. It's the bridge between Ex's bulk processing and Normal mode's surgical edits.

Command Effect
:%norm A; Append ; to every line in file
:'<,'>norm I// Comment out the visual selection
:g/TODO/norm dd Delete every line containing TODO (= :g/TODO/d)
:5,10norm @q Run macro q on lines 5โ€“10
:%norm! 0xx Strip 2 chars from start of every line, ignoring user mappings

Worked example โ€” :%norm I//

Run a Normal-mode sequence on every line.

Step 1 ยท
ex.norm
Step 2 ยท :%norm I// Enter ยท :%norm prefixes every line with '// '.
:%norm prefixes every line with '// '.

Like a macro that doesn't need recording. Combine with :g for selective application.

โ–ถ Try this in the simulator

Watch

See also: Global ({key::g}) and Vglobal ({key::v}), Ex Ranges, Recording and Playing Macros