How do I paste the contents of a register literally in command-line mode without interpreting special characters?
In command-line mode, {reg} inserts a register's contents — but it processes certain sequences, potentially misinterpreting backslashes, pipe characters, or e
category:
registers
tags:
#registers
#command-line
#search
#editing
How do I paste a register literally in insert mode without triggering auto-indent or special key handling?
When you press x in insert mode to paste a register, Vim inserts the text "as if you typed it" — meaning autoindent, textwidth, and other insert behaviors can
category:
registers
tags:
#registers
#insert-mode
#editing
How do I append text to a named register programmatically without re-recording a macro?
Vim registers are just strings, and you can read and write them directly using the :let command.
category:
registers
tags:
#registers
#vimscript
#macros
#editing
How do I paste the name of the alternate (previously edited) file into the buffer?
The # register holds the name of the alternate file — the file you were editing just before the current one.
category:
registers
tags:
#registers
#buffers
#navigation
#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 append yanked text to an existing register without overwriting it in Vim?
Using an uppercase register letter with any operator appends to the register instead of replacing it.
category:
registers
tags:
#registers
#yank
#delete
#editing
#normal-mode
How do I swap two words in Vim using visual paste without any plugins?
When you paste over a visual selection in Vim, the displaced text is moved into the unnamed register "".
category:
registers
tags:
#registers
#visual-mode
#editing
#text-objects
#normal-mode
How do I search for the contents of a register without typing the pattern manually?
Vim's search register (@/) holds the current search pattern — the same one used by n, N, *, and hlsearch highlighting.
category:
registers
tags:
#registers
#search
#normal-mode
#ex-commands
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 access the X11 primary selection (middle-click buffer) separately from the clipboard in Vim on Linux?
On X11 Linux systems, there are two independent clipboard-like buffers: the primary selection (") and the clipboard ("+).
category:
registers
tags:
#registers
#clipboard
#linux
#x11
#advanced
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 insert today's date into a Vim buffer using the expression register?
<C-r>=strftime('%Y-%m-%d')<CR>
The expression register ("=) lets you evaluate any Vimscript expression and insert its result inline.
category:
registers
tags:
#registers
#insert-mode
#expression-register
#dates
How do I programmatically set a register's content or pre-load a macro using setreg()?
The setreg() VimScript function lets you populate any register with arbitrary content directly from the command line or a script — no recording required.
category:
registers
tags:
#registers
#macros
#vimscript
#normal-mode
How do I copy the contents of one register into another register?
Vim's :let command lets you read and write register contents as strings, making it possible to copy, combine, or modify register values without ever leaving the
category:
registers
tags:
#registers
#ex-commands
#editing
#normal-mode
How do I paste back a small deletion (like a deleted character) while in insert mode?
In insert mode, - pastes the contents of the small delete register ("-).
category:
registers
tags:
#registers
#insert-mode
#editing
How do I insert the result of a Vimscript expression as a new line?
The :put ={expr} command evaluates a Vimscript expression and inserts the result as a new line below the cursor.
category:
registers
tags:
#registers
#ex-commands
#insert-mode
#normal-mode
How do I copy the current file's path into the system clipboard from Vim?
The % register always holds the name of the current file (as a relative path).
category:
registers
tags:
#registers
#editing
#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 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