Skip to content
Vim

Registers (Multi-Clipboard)

Store yanks/deletes in named registers and paste from them.

By EZ4Code Team
registerclipboardyank

Code

:reg                 " show all registers
"ayy                 " yank current line into register a
"ap                  " paste from register a
"+yy                 " yank line to system clipboard (+)
"*p                  " paste from system selection (*)
"                    " the unnamed register (last yank/delete)
0                    " register 0: last yank
1-9                  " numbered: last deletes (1 = most recent)
.                    " last inserted text
%                    " current file name
/                    " last search pattern

" Clear a register: yank into it, or set to empty
:let @a = ""

" Append to a register with uppercase
"Ayy                 " append current line to register a

Explanation

Registers are Vim's multiple clipboards. " is the unnamed register (filled by every yank/delete). a–z are named (use "a before an operator like y/d to target it); A–z append. 0 holds the last yank, 1–9 hold recent deletes. + is the system clipboard (requires +clipboard build); * is the X primary selection. :reg lists everything. To paste, type "ap (register name then p/P). Macros are stored in registers too, so "ayy then "ap is also how you'd inspect a macro.

More Vim Snippets