Normal (:norm)
Run Normal-mode keystrokes from Ex.
: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.
Like a macro that doesn't need recording. Combine with :g for selective application.
Watch
- ๐บ #0426 :set incsearch (not yet published)
- ๐บ #0427 :set ignorecase / smartcase (not yet published)
See also: Global ({key::g}) and Vglobal ({key::v}), Ex Ranges, Recording and Playing Macros