Registers

A dictionary of named clipboards built from one primitive

Keys: "a, "A, "0, "-, "+, "*, "/, ":, "., "%, "#, "=, "_, p, P, y, d

A register is a named slot. Yank/delete writes; put reads. The unnamed, named, numbered, clipboard, and special registers are all the same thing โ€” different keys.

Most editors have one clipboard. Vim has fifty-something โ€” and they're all the same thing. Once you see the model, every command that touches yanked or deleted text becomes obvious. This is the single most leveraged piece of Vim's design to understand.

The model

A register is a named slot. Each register holds a piece of text plus a type (charwise, linewise, or blockwise). Vim has a fixed set of registers, identified by a single character โ€” aโ€“z, plus numbers, plus a handful of special punctuation. To address one, type " followed by the register name.

Yank this line into register a
KeyNote
"
a
y
y
Put register a after the cursor
KeyNote
"
a
p

That's it. "a selects register a for the next operation. yy writes a line into it. p reads from the most recently selected register and inserts. The whole register interface is built from those three pieces: select, write, read.

Looking inside

Run :reg to see every register's contents. This is one of the most useful debugging commands in Vim โ€” most "why did that paste do that" mysteries get solved by reading :reg.

Inspecting registers with :reg

The full set

Register Name Written by Notes
"" Unnamed Every yank, delete, change The implicit default for y, d, c, p
"aโ€“"z Named (lowercase) Explicit selection only Yours to use; never overwritten implicitly
"Aโ€“"Z Named (append) Explicit selection (uppercase) Appends to the lowercase counterpart
"0 Last yank Yank only โ€” never delete Survives between deletes
"1โ€“"9 Numbered (deletes) Each multi-line delete shifts entries down "1 = most recent delete
"- Small delete Sub-line deletes that don't specify a register x, dw, di"
"+ System clipboard Yank/delete with explicit selection Cross-application paste
"* Selection clipboard Same; X11 primary selection On macOS/Windows, often aliased to "+
"/ Last search Every search (/, ?, *, #) Read-only effect from searches; writable
": Last Ex command Every :-command @: re-runs it
". Last inserted text Each Insert-mode session Read-only; useful in mappings
"% Current filename Vim Read-only
"# Alternate filename Vim Read-only; the previously-edited file
"= Expression When you read it Prompts for a Vimscript expression
"_ Black hole Throws writes away; reads as empty Use to delete without polluting other registers

Common patterns

Pattern Why it works
"0p Paste the last yank, ignoring intervening deletes.
"_dd Delete a line without overwriting the unnamed register.
"+yiw Yank a word to the system clipboard.
"Ayy Append this line to register a (collect lines).
"1p.. Paste deletes 1, 2, 3 in order โ€” by repeating ., the numbered register paste increments.
"/p Insert the last search pattern as text.
Ctrl-R0 (Insert mode) paste the last yank into the buffer you're typing in.
Ctrl-R=1+1Enter (Insert mode) compute and insert. Expression register live.

When to use which

Default: just don't say a register. Yank, delete, and paste with the unnamed register. Most edits are too short-lived to bother.

Holding a clip across deletes: yank into a named register ("ay) so your subsequent deletes don't clobber it.

System clipboard: prefix with "+ to bridge to and from other apps.

Throwaway delete: prefix with "_ when you're deleting junk you don't want to paste later.

Recovering a recent delete: "1p pastes the most recent line-delete; press . repeatedly to walk back through "1, "2, "3, โ€ฆ

Yank into a named register
Append with uppercase registers

See also: The Unnamed Register, Named Registers, Numbered Registers, Special Registers, Macros Are Just Register Contents, Yank and Put, Recording and Playing Macros, Special Registers Deep Dive