How do I edit a recorded macro to fix a mistake without re-recording it?
"ap, edit, 0"ay$
When a macro has a small mistake, re-recording the entire thing is tedious.
225 results for "paste"
"ap, edit, 0"ay$
When a macro has a small mistake, re-recording the entire thing is tedious.
"#p or <C-r># in insert mode
The # register always contains the name of the alternate file — typically the file you were editing just before the current one.
"/
Vim stores the last search pattern in the special / register.
:let @a=@1
When you delete full lines repeatedly, Vim rotates those deletions through numbered registers.
"_d{motion}
Vim's black hole register (") acts as a write-only sink: anything sent to it is discarded without affecting any other register, including the unnamed register (
:call setreg('b', getreg('a'), getregtype('a'))
Plain register copies like :let @b = @a move text, but they can lose important metadata about register type.
p (in visual mode)
In visual mode, pressing p replaces the selected text with the contents of the default register.
:let @q then use in nnoremap
Macros are stored in registers as plain keystroke strings.
:g/pattern/y A
The :g/pattern/y A command yanks every line matching the pattern and appends it to register a.
command-line #command-line #registers #global #ex-commands #filtering
"-
Vim silently stores every deletion of less than one line in the special "- register (the "small delete" register).
:let @a = @a . @b
You can manipulate register contents directly using the :let command with the @{reg} syntax.
:g/pattern/yank A
The :g command combined with yank A (uppercase A to append) lets you collect every line matching a pattern into a single register without overwriting previous c
command-line #editing #ex-commands #global-command #registers #filtering
:let @q = substitute(@q, 'old', 'new', '')
Vim macros are stored as plain text in named registers, which means you can inspect and modify them directly using :let and :echo.
"qp {edit} 0"qy$ dd
When you record a macro and realize it has a mistake, the easiest fix is to paste the macro's keystrokes as text, edit them, and yank the corrected version back
:%s/pattern/\=@0/g
The \=@0 replacement expression inserts the contents of register 0 (last yank) as the replacement text.
qama{edits}'aq
How it works When a macro needs to jump to different parts of the file and then return to a starting position, marks are the perfect tool.
:[range]yank {reg}
Vim's :[range]yank and :[range]delete Ex commands let you capture arbitrary line ranges into a register from the command line, bypassing the need to move the cu
:call setreg("a", substitute(getreg("a"), "old", "new", "g"))
The getreg() and setreg() functions let you read and write register contents as plain strings, making it possible to surgically edit a macro without re-recordin
q: or <C-f> from : prompt
The command-line window (q:) opens a full Vim buffer containing your Ex command history.
"_d
The "d command deletes text using the black hole register ("), which discards the deleted content instead of storing it.