How do I transfer diff hunks between files in Vim's diff mode?
dp and do
When comparing two files side by side in Vim's diff mode (:diffsplit or vim -d file1 file2), you often want to accept or push individual changes between the fil
dp and do
When comparing two files side by side in Vim's diff mode (:diffsplit or vim -d file1 file2), you often want to accept or push individual changes between the fil
<C-\><C-n>
While works to leave insert or visual mode, it does not work in every situation — particularly in terminal mode (:terminal), where is consumed by the running
g<C-g>
While shows basic file info (filename, line count, position), g provides a much more detailed statistical breakdown of your file or visual selection.
]m / [m / ]M / [M
When navigating large source files, ]m and [m let you jump directly to the start of the next or previous method.
K
Pressing K in normal mode runs a lookup program on the word under the cursor.
navigation #navigation #help #documentation #normal-mode #keywordprg
zz / zt / zb
Vim's z scroll commands reposition the screen relative to the cursor without moving the cursor itself.
navigation #navigation #scrolling #viewport #cursor-position
( ) { } [[ ]]
Vim provides structural navigation motions that move by sentences, paragraphs, and sections.
:pop or <C-t>
When you jump to a tag definition with , Vim pushes your location onto a tag stack.
w vs W, b vs B, e vs E
Vim distinguishes between "words" (sequences of keyword characters) and "WORDS" (sequences of non-blank characters).
gj and gk
When wrap is enabled, long lines wrap across multiple screen lines.
{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.
:set suffixesadd+=.js,.ts,.py
In many programming languages, import statements reference modules without file extensions (e.
g; and g,
Vim tracks every position where you made a change in the changelist.
) and (
The ) and ( motions move by sentence boundaries.
<C-i>
Every time you make a "jump" — using G, /, %, :tag, , or similar commands — Vim records your position in the jump list.
g_
g moves the cursor to the last non-blank character of the current line — skipping trailing spaces and tabs.