How do I use yanked text as the replacement in a substitute command?
:%s/pattern/\=@0/g
The \=@0 replacement expression inserts the contents of register 0 (last yank) as the replacement text.
36 results for "named register paste"
:%s/pattern/\=@0/g
The \=@0 replacement expression inserts the contents of register 0 (last yank) as the replacement text.
visual select + d, move, P
To swap two pieces of text, delete the first selection, navigate to the second, select it, and paste.
"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.
"1p then u.u.u.
Vim stores your last 9 deletions (of one line or more) in the numbered registers "1 through "9.
registers #registers #editing #normal-mode #undo-redo #paste
: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
gp
The standard p command pastes text after the cursor but leaves the cursor at the beginning of the pasted text.
: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.
:t {address}
How it works The :t command (short for :copy) copies one or more lines and places them below the specified address.
qQ...q
When you record a macro into register q with qq.
<C-r>{register}
Pressing followed by a register name in insert mode inserts the contents of that register at the cursor position without leaving insert mode.
"-
Vim silently stores every deletion of less than one line in the special "- register (the "small delete" register).
: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
: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
<C-w>
Pressing in insert mode deletes the word before the cursor instantly, without requiring you to switch to normal mode.