How do I use a register value as the replacement string in a substitution?
:%s/pattern/\=@a/g
How it works In Vim's substitute command, the replacement string can be a Vimscript expression when prefixed with \=.
197 results for "registers"
:%s/pattern/\=@a/g
How it works In Vim's substitute command, the replacement string can be a Vimscript expression when prefixed with \=.
:%s/pattern/\=@0/g
The \=@0 replacement expression inserts the contents of register 0 (last yank) as the replacement text.
:t {address}
How it works The :t command (short for :copy) copies one or more lines and places them below the specified address.
<C-r>{register}
Pressing followed by a register name in insert mode inserts the contents of that register at the cursor position without leaving insert mode.
:m {address}
How it works The :m command (short for :move) moves one or more lines to after the specified address.
:let @q = 'commands'
Macros in Vim are just text stored in named registers.
:let @a = "content"
When a recorded macro has a typo or needs a small tweak, you don't have to re-record it entirely.
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.
:put a ... edit ... "ayy
Recorded macros are stored as plain text in registers, but editing them by re-recording is tedious for complex sequences.
<C-r>=expression<CR>
The expression register ("=) evaluates Vimscript expressions and returns the result.
registers #registers #insert-mode #expression #calculator #vimscript
@"
Vim macros are stored in registers — and you can execute any register as a macro with @{register}.
"add
How it works When you delete text in Vim with commands like dd, dw, or x, the deleted text goes into the unnamed register and the numbered registers (1-9).
":p
The : register holds the most recently executed Ex command.
registers #registers #ex-commands #normal-mode #productivity
<C-r><C-o>{register}
The standard {reg} pastes register contents in Insert mode, but Vim may auto-indent multi-line text to match the current indentation level — sometimes manglin
".p
The ".
registers #registers #editing #insert-mode #normal-mode #productivity
":
The : register contains the last Ex command that was executed.
<C-f> (from command-line mode)
When you are partway through typing a long or complex Ex command on the : prompt, you can press to open the command-line window.
"+y
The "+y command yanks (copies) text into the system clipboard register, making it available to paste in other applications outside of Vim.
"/ register
The / register contains the most recent search pattern.
:redir @a | command | redir END
The :redir command redirects Vim's command output to a register, file, or variable.