How do I highlight a pattern in Vim without jumping the cursor to the next match?
:let @/ = 'pattern'
Writing to the @/ register via :let @/ = 'pattern' sets Vim's last-search pattern directly — without performing a search or moving the cursor.
:let @/ = 'pattern'
Writing to the @/ register via :let @/ = 'pattern' sets Vim's last-search pattern directly — without performing a search or moving the cursor.
:set opfunc and g@
Vim's operatorfunc option lets you define your own operators — just like the built-in d, y, or c — that accept any motion or text object.
:[range]normal @q
The :[range]normal @q command replays the macro in register q on every line within a given range.
:'<,'>norm I//
After making a visual selection, :norm {commands} executes normal-mode keystrokes on every line in the range.
\@= and \@! and \@<= and \@<!
Vim's regex engine supports zero-width lookahead and lookbehind assertions using the \@=, \@!, \@<=, and \@<! atoms.
{count}@{register}
Prefix any macro execution with a count to repeat it that many times in a single command.
g* and g#
The and # commands search for the exact whole word under the cursor (with word boundaries \).
[[ and ]]
[[ and ]] navigate between section boundaries — typically the start of the previous or next top-level block.
"-
Vim silently stores every deletion of less than one line in the special "- register (the "small delete" register).
:let @q =
Instead of recording a macro with q, you can assign any string directly to a named register using :let @{register} = 'keys'.
:earlier
Vim's undo history is not just a linear list of changes — it records timestamps too.
:tab split
:tab split opens the current buffer in a brand new tab page, giving you a second independent view of the same file.
!{motion}{command}
The ! operator filters the text covered by a motion through an external shell command, replacing the original lines with the command's stdout.
zx
The zx command resets and recomputes all folds in the current window based on the current foldmethod.
:%s/pattern//gn
The n flag on the substitute command reports the number of matches without performing any substitution.
@"
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.
:call setreg('"', @", 'l')
Vim registers carry not just their text content but also a type: charwise (c), linewise (l), or blockwise (b).