How do I append yanked text to an existing register without overwriting it in Vim?
"Ay{motion}
Using an uppercase register letter with any operator appends to the register instead of replacing it.
61 results for "named register paste"
"Ay{motion}
Using an uppercase register letter with any operator appends to the register instead of replacing it.
:set clipboard=unnamedplus
Setting clipboard=unnamedplus makes Vim's default yank and paste use the system clipboard.
: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
:%s/pattern/\=@0/g
The \=@0 replacement expression inserts the contents of register 0 (last yank) as the replacement text.
:let @a = '...'
When a recorded macro contains a typo or needs a small tweak, you can modify it directly via the :let command rather than re-recording the entire sequence.
"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
:let @q = @a . @b
Macros in Vim are stored as plain text in named registers.
"ap, edit, "ayy
Vim stores macros in registers, which means you can paste a macro's contents into a buffer, edit it as regular text, and yank it back into the register.
visual select + d, move, P
To swap two pieces of text, delete the first selection, navigate to the second, select it, and paste.
:put =execute('{cmd}')
The :put =execute('{cmd}') idiom inserts the output of any Vim Ex command as text in your buffer.
registers #registers #ex-commands #command-line #normal-mode
<C-r><C-o>a
When you paste multiline snippets from a register while in Insert mode, default insertion can trigger indentation and formatting side effects line by line.
registers #registers #insert-mode #formatting #indentation #editing
:let @a = substitute(@a, 'old', 'new', 'g')
After recording a macro or yanking text into a named register, you may need to tweak it — fix a typo in a recorded macro, change a variable name in yanked tex
:let @a = "value"
The :let @{reg} = expr command lets you assign any string or expression directly into a named register without entering insert mode or performing a yank.
"-
Vim silently stores every deletion of less than one line in the special "- register (the "small delete" register).
qQ...q
When you record a macro into register q with qq.
:put ={expression}
The :put command inserts the contents of a register as a new line below the cursor.
"Ayy
The "Ayy command appends the current line to register a instead of overwriting it.
qA
If you finish recording a macro and realize you forgot a step, you don't need to re-record the whole thing.
macros #macros #registers #normal-mode #editing #productivity
:let @q .= "keys"
The string concatenation assignment :let @q .
:enew | setlocal buftype=nofile bufhidden=wipe noswapfile
A scratch buffer is a temporary, unnamed buffer that exists only in memory — it won't prompt you to save when you close it and leaves no trace on disk.
buffers-windows #buffers #editing #ex-commands #productivity #workflow