How do I edit a macro without re-recording it?
:let @q = substitute(@q, 'old', 'new', '')
Vim macros are stored as plain text in named registers, which means you can inspect and modify them directly using :let and :echo.
953 results for ":normal"
:let @q = substitute(@q, 'old', 'new', '')
Vim macros are stored as plain text in named registers, which means you can inspect and modify them directly using :let and :echo.
<C-o>zvzz
Jumping backward with is fast, but in folded or dense files it can land you in a collapsed section or near the edge of the screen, forcing extra cleanup keystro
gN
Most users know gn for selecting the next search match, but its counterpart gN is the real power move when you need to work backward through matches.
visual-mode #visual-mode #search #motions #editing #normal-mode
gp
The standard p command pastes text after the cursor but leaves the cursor at the beginning of the pasted text.
<C-v>I
Visual block mode's I command lets you type once and have the text inserted at the cursor column across all selected lines simultaneously.
gcip
The vim-commentary plugin exposes gc as a comment operator, which means it composes with any Vim motion or text object.
plugins #plugins #editing #commenting #text-objects #normal-mode
reg_recording() and reg_executing()
Vim exposes two built-in functions for querying the current macro state: regrecording() and regexecuting().
'[ and ']
Vim automatically sets two special marks after every change, yank, or put operation: '[ and '].
10@a
The 10@a command replays the macro recorded in register a exactly 10 times.
<C-w>}
How it works The } command opens a preview window showing the tag definition of the word under your cursor.
:m.+1 and :m.-2
The :move (:m) command relocates a line to a new position without cutting and pasting.
:sort r /pattern/
The :sort r /pattern/ command sorts lines using the matched portion of the regex as the sort key.
zj
When your file uses folds, zj and zk let you navigate directly to fold boundaries — jumping to the start of the next fold below or the end of the previous fol
\%'m
Vim's \%'m regex atom matches the exact position of mark m in a search pattern.
gd
The gd command jumps to the local definition of the word under the cursor.
<C-v> (in visual mode)
Once you are in any visual mode, pressing v, V, or switches to charwise, linewise, or blockwise visual mode respectively — without cancelling the current sele
gw{motion}
The gw operator reformats text just like gq, but leaves the cursor exactly where it started.
it and at
Vim provides two built-in text objects for HTML and XML tags: it (inner tag) and at (a tag).
editing #text-objects #editing #visual-mode #html #normal-mode
l (in :%s///gc confirm prompt)
When running an interactive substitution with the c flag (e.
editing #search #editing #substitution #ex-commands #normal-mode
matchadd('Group', 'pattern', priority)
matchadd() accepts an optional third argument: a priority integer that controls which match wins when two patterns cover the same text.