Special Registers

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

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

Vim provides several read-only registers that contain useful state: "/ is the last search, ": the last Ex command, ". the last inserted text, "% the current filename, "# the alternate file, "= the expression register, and "_ the black hole.

Beyond the alphabetic and numbered registers, Vim has a small zoo of special registers. Most are read-only โ€” Vim writes to them automatically as you work, and you read from them when useful.

Register Holds Useful for
"/ Last search pattern Reusing search in :s
": Last Ex command Pasting it to edit and re-run
". Last inserted text Re-typing the last Insert content
"% Current filename Inserting it in commands or buffer
"# Alternate (previous) filename Switch-to-other-file shortcut
"= Expression register (interactive) Insert computed values
"_ Black hole โ€” write-only, discards text Delete without clobbering registers
"/ โ€” last search
": โ€” last Ex command
". โ€” last insert
"% / "# โ€” filenames
"= โ€” expression register
"_ โ€” black hole

See also: Registers, Special Registers Deep Dive, Pattern Search, Substitute (:s)