How do I move the cursor to the horizontal midpoint of the current screen view?
gm
The gm command moves the cursor horizontally to the middle of the current screen width on the current line.
gm
The gm command moves the cursor horizontally to the middle of the current screen width on the current line.
y/{pattern}<CR>
Any operator in Vim can take a search motion as its argument.
:set virtualedit=onemore
By default, Vim's cursor cannot go past the last character of a line in normal mode — pressing $ lands on the final character, not after it.
g^ and g$
When wrap is on, long lines wrap visually across multiple screen lines.
!{motion}sort
The ! operator in Vim filters a motion's text through an external shell command, replacing it with the output.
iW vs iw
Vim has two flavors of the "inner word" text object that are easy to confuse: iw (lowercase) and iW (uppercase).
flash.nvim
flash.
dgn
The gn motion is a versatile text object that selects the next occurrence of the last search pattern.
editing #editing #search #text-objects #normal-mode #motions
cgn...{text}<Esc>.
The cgn + .
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
v2ap
In Vim, text objects accept a count prefix in visual mode, letting you select multiple consecutive text objects in one keystroke.
/pattern/e+2
Vim's search command supports an offset suffix that controls where the cursor lands after a match.
expand('<cfile>')
The expand('') function returns the filename that Vim sees under the cursor — the same file that gf would open.
command-line #command-line #ex-commands #navigation #editing #motions
>%
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.
[#
Vim includes built-in motions for navigating C preprocessor conditional blocks: [# jumps backward to the previous unmatched #if or #else, and ]# jumps forward t
d3aw
Most Vim users know you can put a count before an operator (3dw) or use a text object once (daw).
editing #text-objects #editing #delete #normal-mode #motions
g0
When wrap is on, a long buffer line can span multiple screen (display) lines.
navigation #navigation #motions #wrap #display-lines #normal-mode