How do I edit a recorded macro by treating it as plain text?
"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
Search Vim Tricks
Searching..."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
g+
Vim's undo history is a tree, not a linear stack.
d'a
Named marks are not just jump destinations — they serve as motion targets for any operator.
navigation #navigation #marks #editing #motions #normal-mode
:s/\v(\w+)\s+(\w+)/\2 \1/
By using capture groups in a substitute command with very magic mode (\v), you can swap two adjacent words in a single operation.
:[range]g/pattern/command
The :global command accepts an optional line range prefix that restricts which lines it even considers matching.
/pattern/;+3
In Vim's range notation, a semicolon (;) between two addresses makes the second address relative to the line the first address matched, not to the current curso
:g/^./,/^$/join
The :g/^.
command-line #command-line #editing #global #formatting #paragraphs
:reg {name}
The :reg {name} command displays the current contents of one or more named registers in a formatted listing.
>G
The >G command applies a right-indent shift to every line from the cursor through the last line of the buffer.
:args {pattern}
The :args command sets Vim's argument list to all files matching a glob pattern.
:set nomore
When a Vim command produces output that exceeds the terminal height, Vim pauses and displays a -- More -- prompt, requiring you to press a key to continue.
{count}r{char}
The {count}r{char} command replaces a precise number of characters starting at the cursor position with a single repeated character.
:e %:h
The command :e %:h opens netrw (Vim's built-in file browser) in the directory that contains the current file.
command-line #command-line #navigation #buffers #netrw #editing
:.t$
The Ex command :.
:s/pattern/~/
In a Vim substitution, using ~ as the replacement string repeats the replacement text from the most recent :s command.
:noautocmd {cmd}
The :noautocmd (abbreviated :noa) prefix suppresses all autocommand events for the duration of the command that follows it.