How do I append additional keystrokes to a recorded macro using Vimscript without re-recording it?
:let @q .= "keys"
The string concatenation assignment :let @q .
:let @q .= "keys"
The string concatenation assignment :let @q .
:g/\(.\+\)\n\1/d
The :g command with a backreference pattern can detect and delete consecutive duplicate lines in one pass.
dV{motion}
In operator-pending mode — the brief state after typing an operator like d, c, or y but before entering the motion — you can prefix the motion with v, V, or
/pattern/e+2
Vim's search command supports an offset suffix that controls where the cursor lands after a match.
:reg a b c
The :reg (alias :registers) command accepts a string of register names as its argument.
dp
In Vim's diff mode, dp (diff put) and do (diff obtain) are single-keystroke shorthands for :diffput and :diffget.
buffers-windows #diff #buffers-windows #editing #normal-mode
\%'m
Vim's \%'m regex atom matches the exact position of mark m in a search pattern.
getreginfo('a')
getreginfo('{reg}') (Vim 8.
"qp {edit} 0"qy$ dd
When you record a macro and realize it has a mistake, the easiest fix is to paste the macro's keystrokes as text, edit them, and yank the corrected version back
zr
zr ("reduce" fold level) decrements the global foldlevel option by 1, opening the next layer of folds across the entire file.
<Cmd>
The pseudo-key in Neovim allows a mapping to execute an Ex command directly, without going through command-line mode.
Q
In Neovim, the Q key is mapped to replay the last executed macro — the same as @@ in both Vim and Neovim.
>%
Vim's > operator (indent) works with any motion or text object — including %, which jumps to the bracket, parenthesis, or brace matching the one under the cur
editing #editing #indentation #text-objects #normal-mode #motions
d'a
Named marks are not just jump destinations — they serve as motion targets for any operator.
navigation #navigation #marks #editing #motions #normal-mode
>G
The >G command applies a right-indent shift to every line from the cursor through the last line of the buffer.
{count}r{char}
The {count}r{char} command replaces a precise number of characters starting at the cursor position with a single repeated character.
[* and ]*
The [ and ] motions (also written as [/ and ]/) let you jump directly to the opening / or closing / of a C-style block comment.
matchadd()
The matchadd() function adds a persistent highlight for a pattern in the current window without touching your search register or interfering with n/N navigation
qa{motions}@aq
A recursive macro is one that calls itself at the end of its own recording.
:'<,'>w !{cmd}
The :'w !{cmd} command writes the visually selected lines to the stdin of an external shell command — without modifying the buffer.