What is the selection register in Vim and how do you use it?
"*p
The register represents the primary selection (middle-click paste in X11).
161 results for "paste"
"*p
The register represents the primary selection (middle-click paste in X11).
"_dP in visual mode
Use "_dP which deletes the selection into the black hole register and pastes before.
"0p in visual mode
When you paste over a visual selection with p, Vim replaces the selection with the register contents — but it also puts the deleted selection into the unnamed
<C-r>a
In insert mode, press followed by the register name.
"*p vs "+p
How it works Vim has two system clipboard registers that interact with the operating system: " -- the selection register (PRIMARY selection on Linux/X11, clipbo
:call setreg('"', @", 'l')
Vim registers carry not just their text content but also a type: charwise (c), linewise (l), or blockwise (b).
<C-r><C-r>{register}
In insert mode, {reg} pastes from a register but treats certain bytes as key inputs — so a register containing \n triggers a newline, \x08 triggers backspace,
gp
The standard p command pastes text after the cursor but leaves the cursor at the beginning of the pasted text.
"1pu.u.u.
Vim stores the last 9 deletions in numbered registers 1-9, with the most recent in register 1.
]p
The ]p command pastes text and adjusts its indentation to match the current line.
y (in visual mode)
In visual mode, pressing y yanks (copies) the selected text into the default register.
"%p
Vim has several read-only registers that hold special values.
"1p ... "2p ... "9p
Vim maintains a numbered register history from "1 through "9 that stores your last 9 deletes and changes.
"ap, edit, "add
Since macros are stored in registers, you can paste the register content into the buffer, edit it, and yank it back.
"0p
Register 0 (the yank register) always contains the text from your most recent yank command — and unlike the unnamed register, it is never overwritten by delet
Paste with "ap and execute keys manually
To debug a macro, paste its contents into the buffer, read each keystroke, and execute them one at a time to find where the macro goes wrong.
"1p then u then . to cycle
Vim stores your last 9 deletions in numbered registers "1 through "9.
:let @a = system('cmd')
You can populate any Vim register with the output of an external shell command using :let @{register} = system('{command}').
"/p
Vim stores the last search pattern in the search register "/.
<C-r><C-o>"
The {register} sequence in insert mode pastes register contents literally — without triggering auto-indentation, abbreviations, or mappings.