How do I paste text below the current line?
p
The p command pastes (puts) the contents of the default register after the cursor.
197 results for "registers"
p
The p command pastes (puts) the contents of the default register after the cursor.
@=
The @= command lets you type a Vimscript expression and execute the result as if it were a macro.
[p
When you copy code from one indentation level and paste it at another, p preserves the original indentation, leaving your code misaligned.
When recording a macro, you can execute another macro inside it by pressing @b (or any register) during the recording.
:s/\d\+/\=submatch(0)+1/g
The \= prefix in a :substitute replacement field tells Vim to evaluate the following as a Vimscript expression rather than treating it as a literal string.
qaq
How it works To clear a macro register, you simply start recording into that register and immediately stop.
:let @+ = expand('%:p')
Sometimes you need to share or use the full path of the file you're editing — for a terminal command, a config file, or a chat message.
"ap, edit, 0"ay$
When a macro has a small mistake, re-recording the entire thing is tedious.
"/
Vim stores the last search pattern in the special / register.
:let @a = substitute(@a, 'old', 'new', 'g')
After recording a macro or yanking text into a named register, you may need to tweak it — fix a typo in a recorded macro, change a variable name in yanked tex
:keeppatterns %s/old/new/g
The :keeppatterns modifier runs any Ex command without modifying Vim's last search pattern (stored in @/).
command-line #search #ex-commands #command-line #substitute #registers
:%s/pattern//gn
The n flag on the substitute command makes it report the match count without actually performing any replacement.
: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.
qa<C-r>=expression<CR>q
How it works The expression register (=) lets you evaluate Vimscript expressions and insert the result.
<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.
<C-w>N
When using Vim's built-in :terminal, the buffer is in Terminal-Job mode by default, meaning all keystrokes go to the running shell.
p (in visual mode)
In visual mode, pressing p replaces the selected text with the contents of the default register.
: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}').