How do I perform arithmetic calculations and insert the result without leaving insert mode?
The expression register ("=) lets you evaluate any Vimscript expression and insert the result directly into the buffer — all without leaving insert mode.
category:
registers
tags:
#registers
#insert-mode
#editing
#ex-commands
How do I programmatically set a register's content in Vim without yanking?
Vim's :let command lets you assign a value directly to any named register without performing a yank or delete operation.
category:
registers
tags:
#registers
#macros
#vimscript
#ex-commands
#normal-mode
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 delete or change text without overwriting my previously yanked text?
Vim's black hole register (") acts as a write-only sink: anything sent to it is discarded without affecting any other register, including the unnamed register (
category:
registers
tags:
#registers
#delete
#editing
#normal-mode
How do I insert the output of a shell command directly into my buffer?
:put =system('cmd') lets you insert the output of any shell command as new lines in your buffer without leaving Vim.
category:
command-line
tags:
#ex-commands
#shell
#registers
#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 programmatically set a register's content in Vimscript to pre-load a macro?
:let @{reg} = 'string' directly assigns content to any named register from Vimscript.
category:
registers
tags:
#registers
#macros
#ex-commands
#normal-mode
How do I execute a recorded macro a specific number of times?
Prefix the @ macro-execution command with a count to run the macro that many times in a row.
category:
macros
tags:
#macros
#registers
#normal-mode
#editing
How do I save a recorded macro permanently so it survives Vim restarts?
Macros recorded with q{register} are stored in registers and lost when Vim exits.
category:
macros
tags:
#macros
#registers
#config
How do I recover text from older deletions using Vim's numbered registers?
Vim automatically stores your deletion history in numbered registers "1 through "9.
category:
registers
tags:
#registers
#editing
#normal-mode
#undo-redo
How do I run a macro a specific number of times without using a recursive macro?
Prefix a macro invocation with a count to execute it up to N times in a single command.
category:
macros
tags:
#macros
#registers
#normal-mode
#editing
How do I use a Vim expression as the replacement string in a :s substitution?
Vim's :s command normally replaces matches with a literal string.
category:
command-line
tags:
#search
#editing
#ex-commands
#command-line
#registers
How do I edit the contents of a macro register without re-recording it?
:let @q = substitute(@q, 'old', 'new', 'g')
When a recorded macro has a typo or needs a small tweak, re-recording the entire thing is error-prone.
category:
macros
tags:
#macros
#registers
#editing
#normal-mode
How do I create or edit a Vim macro as a plain string without re-recording it?
Macros are just strings stored in named registers.
category:
macros
tags:
#macros
#registers
#ex-commands
How do I programmatically load text or a macro into a named register from the command line?
:let @{register}=".
category:
registers
tags:
#registers
#macros
#command-line
#vimscript
How do I create a macro that repeats itself automatically until there is nothing left to process?
A recursive macro calls itself at the end of its own definition, causing it to run repeatedly until Vim hits an error — such as reaching the end of the file o
category:
macros
tags:
#macros
#registers
#editing
#normal-mode
How do I edit a file without overwriting the alternate buffer?
Every time you open a file with :edit, Vim updates the alternate file register (#) to the previous buffer.
category:
buffers-windows
tags:
#buffers
#ex-commands
#registers
#navigation
How do I highlight a pattern without executing a search or moving the cursor?
Assigning a string directly to the search register @/ with :let causes Vim to highlight all matches (if hlsearch is enabled) without performing a search or movi
category:
registers
tags:
#registers
#search
#normal-mode
#ex-commands
How do I browse and restore previously deleted text using Vim's numbered registers?
"1p then u. to cycle through delete history
Vim silently maintains a rolling history of your last 9 deletions in numbered registers "1 through "9.
category:
registers
tags:
#registers
#editing
#normal-mode
#undo-redo
How do I split a complex Vim macro into reusable subroutines?
Record worker macro in @b, call it from @a with @b
Complex macros are hard to debug and maintain when crammed into a single register.
category:
macros
tags:
#macros
#registers
#editing