How do I programmatically load text or a macro into a named register from the command line?
:let @a="text"
:let @{register}=".
351 results for "registers"
:let @a="text"
:let @{register}=".
qQ
Recording a macro with an uppercase register letter appends to the existing macro in the corresponding lowercase register instead of overwriting it.
:let @q = "dwelp"
Recording macros with q works well for simple sequences, but complex macros with special keys can be hard to get right in one take.
".p
The ".
registers #registers #editing #insert-mode #normal-mode #productivity
qa<C-r>=expression<CR>q
How it works The expression register (=) lets you evaluate Vimscript expressions and insert the result.
:let @/='\V'.escape(@", '\\')
When you yank text that contains regex characters like .
<C-a> (insert mode)
While in insert mode, pressing re-inserts the exact text you typed during your previous insert session.
<C-r><C-w>
When typing a command on the Vim command line, pressing inserts the word currently under the cursor.
:execute 'vimgrep /' . @/ . '/gj **/*'
If you already refined a search interactively with / or ?, retyping that pattern for project-wide grep is repetitive and error-prone.
p (in visual mode)
In visual mode, pressing p replaces the selected text with the contents of the default register.
v:event
The v:event dictionary is populated inside certain autocommand callbacks with data specific to that event.
getchar()
getchar() blocks and waits for the user to press a key, returning its numeric character code.
:keepalt e {file}
Every time you open a file with :edit, Vim updates the alternate file register (#) to the previous buffer.
buffers-windows #buffers #ex-commands #registers #navigation
searchcount()
The searchcount() function returns a dictionary containing the current search state: which match the cursor is on, how many total matches exist, and whether the
:keeppattern %s/old/new/g
When you run a :s or :%s substitute command, Vim updates the search register (@/) with the substitution pattern.
command-line #ex-commands #search #editing #registers #substitute
:let @a = system('cmd')
You can populate any Vim register with the output of an external shell command using :let @{register} = system('{command}').
:let @/ = "pattern"
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
:let @q .= "j^"
Live macro recording is fast, but adjusting the tail of a macro by re-recording can be risky once it already works in most places.
macros #macros #registers #automation #normal-mode #workflow
<C-r><C-r>
In command-line mode, {reg} inserts a register's contents — but it processes certain sequences, potentially misinterpreting backslashes, pipe characters, or e
"+y
The "+y command yanks (copies) text into the system clipboard register, making it available to paste in other applications outside of Vim.