How do I insert the output of any Vim Ex command directly into the current buffer?
The :put =execute('{cmd}') idiom inserts the output of any Vim Ex command as text in your buffer.
category:
registers
tags:
#registers
#ex-commands
#command-line
#normal-mode
How do I copy lines to a different location in the file without overwriting my yank register?
The :t command (short for :copy) copies addressed lines to a destination line number, leaving the unnamed register untouched.
category:
command-line
tags:
#ex-commands
#editing
#normal-mode
#registers
How do I apply a recorded macro to a range of lines without re-recording it in Vim?
The :[range]normal @a command runs a recorded macro against every line in a given range.
category:
macros
tags:
#macros
#registers
#ex-commands
#normal-mode
#advanced
How do I make a macro repeat itself until it reaches the end of the file?
A recursive macro calls itself at the end of its recording, causing it to repeat automatically until a motion fails (like j at the last line).
category:
macros
tags:
#macros
#editing
#normal-mode
#registers
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 yank or delete a line range directly into a named register without selecting it visually?
Vim's :[range]yank and :[range]delete Ex commands let you capture arbitrary line ranges into a register from the command line, bypassing the need to move the cu
category:
registers
tags:
#registers
#ex-commands
#editing
#normal-mode
How do I create a macro that repeats itself automatically until it can no longer proceed?
A recursive macro ends by calling itself, so it loops automatically without you pressing @q repeatedly.
category:
macros
tags:
#macros
#registers
#normal-mode
#editing
How do I edit the contents of a macro register using Vimscript without re-recording it?
:call setreg("a", substitute(getreg("a"), "old", "new", "g"))
The getreg() and setreg() functions let you read and write register contents as plain strings, making it possible to surgically edit a macro without re-recordin
category:
registers
tags:
#registers
#macros
#vimscript
#ex-commands
How do I create a self-referential recursive macro that repeats until it fails?
A recursive macro in Vim calls itself at the end of its body, repeating automatically until one of its commands fails.
category:
macros
tags:
#macros
#registers
#advanced
#normal-mode
How do I run a macro a specific number of times at once?
Prefix any macro execution with a count to repeat it that many times in a single command.
category:
macros
tags:
#macros
#registers
#normal-mode
How do I execute buffer text as a macro dynamically?
:let @a=getline('.')<CR>@a
How it works Instead of recording keystrokes interactively, you can write a sequence of Vim commands as plain text in your buffer and then execute that text as
category:
macros
tags:
#macros
#registers
#ex-commands
#editing
How do I paste the result of a calculation or expression in normal mode?
The expression register ("=) lets you evaluate any Vimscript expression and paste the result directly into your buffer from normal mode.
category:
registers
tags:
#registers
#editing
#normal-mode
#productivity
#math
How do I create a recursive macro that repeats itself until it fails?
A recursive macro calls itself at the end of its sequence, creating a loop that automatically repeats until a motion or command fails (such as hitting the last
category:
macros
tags:
#macros
#editing
#normal-mode
#registers
How do I search for text I just yanked using the register?
How it works After yanking text, you can use it directly as a search pattern by inserting the yank register contents into the search prompt.
category:
registers
tags:
#registers
#search
#normal-mode
How do I detect which register was specified before executing a custom mapping in Vim?
When writing custom mappings or operator functions, v:register gives you the register name that the user prefixed the mapping with.
category:
registers
tags:
#registers
#macros
#normal-mode
#ex-commands
How do I insert a register's content literally in insert mode, without triggering auto-indent or mappings?
When you insert a register with {reg} in insert mode, Vim processes the content as if you had typed it — this means autoindent, autoformat, and insert-mode ma
category:
registers
tags:
#registers
#insert-mode
#editing
How do I collect all lines matching a pattern into a register without leaving them in place?
Using :g/pattern/d A you can sweep through the entire buffer and extract every line that matches a pattern into register a, removing them from the buffer in the
category:
registers
tags:
#registers
#ex-commands
#search
#editing
#global
How do I paste the contents of a register at a specific line number without moving my cursor?
How it works The :put Ex command pastes the contents of a register after a specified line.
category:
editing
tags:
#editing
#registers
#ex-commands
How do I paste from a register in insert mode without Vim interpreting special characters?
In insert mode, {reg} pastes from a register but treats certain bytes as key inputs — so a register containing \n triggers a newline, \x08 triggers backspace,
category:
registers
tags:
#registers
#insert-mode
#editing
#paste
How do I briefly highlight text after yanking it to get visual confirmation of what was copied?
The TextYankPost event fires immediately after any yank operation completes — including y, Y, dd, dw, and any other command that writes to a register.
category:
config
tags:
#config
#autocommands
#registers
#visual-mode