Special Registers Deep Dive

%, #, :, ., /, =, _ โ€” the read-only and computed ones.

Keys: %, #, :, ., /, =, _

Beyond the named and numbered registers, Vim has a set of special registers that hold computed or context-dependent values: filename (%), alternate file (#), last command (:), last insert (.), last search (/), expression (=), and the black hole (_).

Beyond aโ€“z and 0โ€“9, Vim has a handful of special registers that hold computed values. Most are read-only.

Register Holds Common use
% Current filename "%p to paste filename
# Alternate filename Reference last edited file
: Last Ex command @: replays it
. Last inserted text ".p to paste what you just typed
/ Last search pattern "/p to see the regex
= Expression evaluator "=1+1Enterp pastes 2
_ Black hole โ€” writes vanish "_dd delete without affecting any other register
+ System clipboard Cross-app cut/paste
* X11 selection clipboard Linux selection (middle-click)

Watch

See also: Special Registers, Inserting from a Register