~ / macros
8
Macros
Record a sequence of keystrokes once and replay it anywhere, on many lines, or as many times as you need.
- 01
Record and replay: q, @ and @@
Record an edit into a register once, then replay it wherever you need it.
q{a-z}q@{a-z}@@ - 02
Replay with a count (and why too many is fine)
Run a macro many times with a count; it stops by itself when it runs out of work.
{count}@{a-z}99@a - 03
Run a macro on many lines: :normal @a
Apply a macro to every line of a range, skipping the lines where it fails.
:%normal @a:'<,'>normal @a:g/{pattern}/normal @a{Visual}@anvim - 04
Add to a macro: qA
Record into the uppercase register to append keys to an existing macro.
q{A-Z}:reg {a-z} - 05
Counting with CTRL-A
Number lines with a copy-and-increment macro, or with g CTRL-A in Visual mode.
<C-a><C-x>{Visual}g<C-a>gvnvim - 06
Edit a macro as text
Paste a register into the buffer, fix it, and yank it back.
"{a-z}p:put {a-z}0"ay$"aYnvim