How do I use count prefixes to amplify motions and operators in Vim?
{count}{motion}
Almost every Vim motion and operator accepts a numeric count prefix that repeats or amplifies the action.
{count}{motion}
Almost every Vim motion and operator accepts a numeric count prefix that repeats or amplifies the action.
^ vs 0
Vim has two distinct motions for moving to the start of a line: 0 goes to column 1 (the absolute start), while ^ goes to the first non-blank character.
navigation #navigation #motions #line-navigation #indentation
`a vs 'a
Vim has two ways to jump to marks: backtick (` `) jumps to the exact line AND column, while apostrophe (') jumps to the line only, positioning the cursor at the
[m and ]m
The [m and ]m motions jump to the start of method/function definitions in languages with brace-delimited blocks.
f{char} ; ,
The f, F, t, and T motions search for a character on the current line.
:nnoremap ]b :bnext<CR>
Mapping ]b and [b to :bnext and :bprev creates an intuitive bracket-style navigation for buffers, matching the convention used by unimpaired.
buffers-windows #buffers-windows #navigation #mapping #buffers
<C-w>_ and <C-w>|
When working with multiple splits, you sometimes need to focus on one window temporarily without closing the others.
:set suffixesadd+=.js,.ts,.py
In many programming languages, import statements reference modules without file extensions (e.
<C-w>_ and <C-w>=
When working with multiple splits, you often want to focus on one window by making it as large as possible, then restore equal sizing when you're done.
g; and g,
Vim tracks every position where you made a change in the changelist.
) and (
The ) and ( motions move by sentence boundaries.
/pattern1/;/pattern2/
Vim's search offsets allow chaining two patterns together with a semicolon.
<C-i>
Every time you make a "jump" — using G, /, %, :tag, , or similar commands — Vim records your position in the jump list.
]q and [q
The vim-unimpaired plugin by Tim Pope provides pairs of bracket mappings for common navigation and toggling tasks.
<C-r><C-f>
While typing a command, inserts the filename under the cursor in the buffer at the command-line prompt.
g_
g moves the cursor to the last non-blank character of the current line — skipping trailing spaces and tabs.
<C-w>gf
gf reads the filename under the cursor and opens it in a new tab page, keeping your current buffer untouched.
:helpgrep {pattern}
:helpgrep searches the full text of every Vim help file for a pattern and loads all matches into the quickfix list.
zl and zh
When a line is longer than the window width and wrap is off, Vim can display only part of it.
:vertical diffsplit {file}
Vim has a built-in diff mode that highlights added, removed, and changed lines between two (or more) buffers.