How do I run text I've yanked or typed as a Vim macro without recording it first?
@"
Vim macros are stored in registers — and you can execute any register as a macro with @{register}.
@"
Vim macros are stored in registers — and you can execute any register as a macro with @{register}.
:norm
:normal (abbreviated :norm) executes a sequence of normal-mode keystrokes on each line of an address range.
:t
The :t command (short for :copy) copies addressed lines to a destination line number, leaving the unnamed register untouched.
[p
When you copy code from one indentation level and paste it at another, p preserves the original indentation, leaving your code misaligned.
:argdo norm @a | update
Combining :argdo with :norm @a lets you apply a recorded macro to every file in Vim's argument list — a powerful pattern for bulk refactoring across a project
<C-x>s
When spell checking is enabled (:set spell), s in insert mode opens a popup menu of suggested corrections for the most recently flagged misspelled word — with
:%!
The ! operator pipes text through a shell command, replacing the selected lines with the command's output.
:%s/pattern//gn
The n flag on the substitute command makes it report the match count without actually performing any replacement.
:call setreg('"', @", 'l')
Vim registers carry not just their text content but also a type: charwise (c), linewise (l), or blockwise (b).
p (in visual mode)
In visual mode, pressing p replaces the selected text with the contents of the default register.
]s / [s / z=
Vim has a built-in spell checker that highlights misspelled words and provides correction suggestions — all without plugins.
]m / [m
Vim's ]m and [m motions navigate between method and function boundaries in curly-brace languages like C, Java, JavaScript, and Go.
dp / do
When reviewing differences between files in Vim's built-in diff mode, dp and do let you selectively apply individual hunks without leaving the editor.
:sort u
The :sort u command sorts all lines in the buffer (or a selected range) alphabetically and removes duplicate lines in a single pass.
:let @q = 'commands'
Macros in Vim are just text stored in named registers.
<C-w>^
Vim tracks the alternate buffer — the last file you were editing before the current one.
* (in visual mode)
In normal mode, searches for the word under the cursor with word-boundary anchors.
"=
The expression register ("=) lets you evaluate any Vim expression and insert its result as text.
P (in visual mode)
When you paste over a visual selection using p (lowercase), Vim replaces the selection with your register contents — but the replaced text overwrites your unn
\v
Vim's default regex mode ("magic") requires backslashes before many special characters: \(, \ , \+, \{.