How do I copy the most recent yank into a named register without yanking again?
When you want to preserve a valuable yank before doing destructive edits, copying register 0 into a named register is safer than re-yanking text.
category:
registers
tags:
#registers
#yanking
#editing
#command-line
#refactoring
How do I preserve the last full-line deletion before register 1 is overwritten?
When you delete full lines repeatedly, Vim rotates those deletions through numbered registers.
category:
registers
tags:
#registers
#editing
#history
#command-line
How do I paste the current Git commit hash directly from Vim using the expression register?
"=system('git rev-parse --short HEAD')->trim()<CR>p
If you frequently write commit references in notes, code comments, or release docs, you can avoid shell context switches and paste the hash straight from Vim.
category:
registers
tags:
#registers
#command-line
#editing
#git
How do I append the current line to a register from command line without using yank?
:let @a .= getline('.') . "\n"
Named registers are usually filled with yanks and deletes, but they are also plain variables you can edit with Vimscript.
category:
registers
tags:
#registers
#command-line
#vimscript
#editing
How do I put a register as true line list so embedded newlines stay split correctly?
Most register pastes are character-oriented, but advanced edits often need to preserve exact line structure.
category:
registers
tags:
#registers
#ex-commands
#scripting
#text-processing
How do I inspect a macro register with escaped control characters so I can debug it safely?
:echo string(getreg('q'))
Macros can fail for subtle reasons: hidden control keys, extra whitespace, or unexpected register contents.
category:
registers
tags:
#registers
#macros
#debugging
#automation
#command-line
How do I capture command-line output directly into a register?
:redir @a | messages | redir END<CR>
When debugging a session or building repeatable edits, it is useful to turn command output into editable text.
category:
registers
tags:
#registers
#command-line
#debugging
#workflow
How do the numbered delete registers work and why does deleted text rotate through registers 1 through 9?
Vim maintains a rotating history of deleted text across registers "1 through "9.
category:
registers
tags:
#registers
#editing
#normal-mode
How do I inspect the contents of specific Vim registers without listing all of them?
The :registers command dumps every register at once, which is noisy when you only care about a handful.
category:
registers
tags:
#registers
#command-line
#macros
#normal-mode
How do I paste register contents in insert mode without triggering auto-indentation?
When you paste a register in insert mode with {reg}, Vim inserts the text as if you had typed it — which means auto-indent, abbreviation expansion, and other
category:
registers
tags:
#registers
#insert-mode
#paste
#autoindent
#editing
How do I save the current search pattern into a named register before it gets overwritten by a new search?
Vim stores the last search pattern in the special / register (@/).
category:
registers
tags:
#registers
#search
#ex-commands
How do I display the contents of only certain registers instead of all of them at once?
The :reg (alias :registers) command accepts a string of register names as its argument.
category:
registers
tags:
#registers
#ex-commands
#normal-mode
How do I inspect a Vim register's full details including its type (charwise, linewise, or blockwise) in Vimscript?
getreginfo('{reg}') (Vim 8.
category:
registers
tags:
#registers
#normal-mode
How do I inspect the current contents of a specific register before pasting or running it as a macro?
The :reg {name} command displays the current contents of one or more named registers in a formatted listing.
category:
registers
tags:
#registers
#macros
#debugging
How do I insert all Vim messages into the current buffer so I can read, search, or save them?
:put =execute('messages')
Vim's :messages command shows recent output — error messages, echo'd values, and diagnostic information — but the display is ephemeral and hard to search.
category:
registers
tags:
#registers
#ex-commands
#debugging
#command-line
How do I programmatically read and write Vim register contents including their type from Vimscript?
The setreg(reg, value, type) and getreg(reg, 1, 1) functions give you full programmatic control over registers, including their type (characterwise, linewise, o
category:
registers
tags:
#registers
#vimscript
#macros
#ex-commands
How do I highlight all occurrences of a yanked word without typing a search pattern?
After yanking text, you can promote it directly to the search register with :let @/ = @".
category:
registers
tags:
#registers
#search
#hlsearch
#normal-mode
How do I check whether a register contains characterwise, linewise, or blockwise text?
The getregtype() function returns the motion type of a register's content — whether it was yanked characterwise, linewise, or as a visual block.
category:
registers
tags:
#registers
#ex-commands
#macros
How do I cycle through the numbered delete registers using the dot command?
When you paste from a numbered register with "1p, Vim's dot command (.
category:
registers
tags:
#registers
#editing
#normal-mode
#undo-redo
How do I read the contents of a Vim register into a variable or expression using Vimscript?
The getreg({name}) function returns the content of any register as a string.
category:
registers
tags:
#registers
#ex-commands