What are Vim's read-only special registers and how do I use them?
". / "% / ": / "# registers
Vim has four read-only special registers that automatically contain useful contextual information.
category:
registers
tags:
#registers
#special-registers
#workflow
#productivity
How do I understand which register Vim uses for each operation?
Vim has 10 types of registers, each serving a specific purpose.
category:
registers
tags:
#registers
#reference
#clipboard
#workflow
How do I write and edit a macro as text instead of recording it live?
Write keystrokes in buffer, then "qy$
Instead of recording a macro in real-time (where mistakes mean starting over), you can write the keystrokes as text in a buffer, edit them visually, and then ya
category:
macros
tags:
#macros
#editing
#registers
#workflow
#best-practices
How do I use Vim as an inline calculator with the expression register?
The expression register ("=) evaluates Vimscript expressions and returns the result.
category:
registers
tags:
#registers
#insert-mode
#expression
#calculator
#vimscript
How do I use the alternate file register to quickly reference the previous file?
"#p or <C-r># in insert mode
The # register always contains the name of the alternate file — typically the file you were editing just before the current one.
category:
registers
tags:
#registers
#buffers
#file-management
#workflow
How do I always access my last yanked text regardless of deletes?
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
category:
registers
tags:
#registers
#paste
#yank
#workflow
How do I paste or reuse my last search pattern?
Vim stores your last search pattern in the / register.
category:
registers
tags:
#registers
#search
#insert-mode
#command-line
How do I paste text in insert mode without triggering auto-indent or mappings?
The {register} sequence in insert mode pastes register contents literally — without triggering auto-indentation, abbreviations, or mappings.
category:
editing
tags:
#insert-mode
#registers
#paste
#indentation
How do I access my delete history beyond the last delete?
Vim maintains a numbered register history from "1 through "9 that stores your last 9 deletes and changes.
category:
registers
tags:
#registers
#undo-redo
#delete
#history
#paste
How do I collect all lines matching a pattern into a register?
The :g/pattern/y A command yanks every line matching the pattern and appends it to register a.
category:
command-line
tags:
#command-line
#registers
#global
#ex-commands
#filtering
How do I yank text into a specific named register for later use?
Vim has 26 named registers (a-z) that act as independent clipboards.
category:
registers
tags:
#registers
#editing
#normal-mode
#yank
#productivity
How do I swap a word with the contents of a register using visual mode?
The viwp command visually selects the word under the cursor and replaces it with the contents of the unnamed register (your last yank or delete).
category:
visual-mode
tags:
#editing
#visual-mode
#registers
#paste
#productivity
How do I save a recorded macro permanently so it persists across Vim sessions?
let @a = 'macro_contents'
Recorded macros are stored in registers, which are lost when you quit Vim (unless viminfo saves them).
category:
macros
tags:
#macros
#config
#registers
#vimrc
#productivity
How do I capture the output of a Vim command into a register or buffer?
:redir @a | {cmd} | redir END
The :redir command redirects the output of Ex commands to a register, file, or variable instead of displaying it on the screen.
category:
command-line
tags:
#command-line
#ex-commands
#registers
#productivity
#advanced
How do I paste the current filename into the buffer?
The % register in Vim always contains the name of the current file.
category:
registers
tags:
#registers
#editing
#insert-mode
#productivity
#filename
How do I paste the last Ex command I ran into my buffer?
The : register holds the most recently executed Ex command.
category:
registers
tags:
#registers
#ex-commands
#normal-mode
#productivity
How do I paste the text I just typed in insert mode?
The ".
category:
registers
tags:
#registers
#editing
#insert-mode
#normal-mode
#productivity
How do I paste from a register while staying in insert mode?
Pressing followed by a register name in insert mode inserts the contents of that register at the cursor position without leaving insert mode.
category:
registers
tags:
#editing
#insert-mode
#registers
#productivity
How do I cycle through my previous deletions to find the one I want to paste?
Vim stores your last 9 deletions (of one line or more) in the numbered registers "1 through "9.
category:
registers
tags:
#registers
#editing
#normal-mode
#undo-redo
#paste
How do I do math calculations without leaving insert mode?
The expression register (=) lets you evaluate Vimscript expressions on the fly and insert the result directly into your text.
category:
registers
tags:
#editing
#insert-mode
#registers
#productivity
#math