How do I jump between diff hunks in a diff view?
]c
In diff mode, ]c jumps to the next change hunk and [c jumps to the previous one.
2125 results for "i' a'"
]c
In diff mode, ]c jumps to the next change hunk and [c jumps to the previous one.
:%s/,/,\r/g
In Vim substitutions, \n and \r behave differently depending on whether they appear in the search pattern or the replacement string — a common gotcha that sur
/\_.pattern
The \.
qa f,ldt,F(p q
This macro swaps two comma-separated arguments inside parentheses by cutting the second argument and placing it before the first.
:'>,'<normal @q
Running a macro over a range usually goes top to bottom, but that can break when the macro inserts or deletes lines.
macros #macros #ex-commands #visual-mode #normal-mode #refactoring
g<C-x>
Most people know decrements one number under the cursor, but g in Visual mode performs a sequential decrement across the selection.
:[range]norm @{register}
The :normal command executes normal-mode keystrokes on each line in a range — including macro playback.
:%s/\(group\)/\1/g
Capture groups in Vim substitute let you match parts of a pattern and reuse them in the replacement.
:put =map(getreg('a', 1, 1), 'toupper(v:val)')
By using getreg() with the list flag and applying map(), you can transform register contents with any Vimscript function before pasting.
:source %
The :source command reads and executes a Vimscript file.
:'<,'>norm @a
Combining :normal with a visual range lets you replay a macro on each line of a selection individually — far more targeted than recursive macros or @@ repeati
Record worker macro in @b, call it from @a with @b
Complex macros are hard to debug and maintain when crammed into a single register.
:%s/pattern/\=expr/g
Prefixing the replacement field of :s with \= tells Vim to evaluate the rest as a Vimscript expression and use its result as the replacement string.
:%s/pattern/\=@a/g
How it works In Vim's substitute command, the replacement string can be a Vimscript expression when prefixed with \=.
:keepjumps normal! gg
Sometimes you need to make a quick structural move (for example, jump to top, inspect context, then return) without polluting jump navigation history.
systemlist()
systemlist({cmd}) runs a shell command and returns the output as a list of strings, one per line — unlike system() which returns everything as a single string
:argdo normal @a
The :argdo command applies any Ex command to every file in the argument list.
:s/\v\d+/\=printf('%04d', submatch(0))/g
Substitution expressions let Vim compute each replacement dynamically, which is ideal when plain capture groups are too limited.
:s/,/,\r/g
In Vim's :substitute command, \r in the replacement string inserts a literal newline — it splits the line at that point.
:setlocal winfixwidth
When you use a sidebar-style split for file trees, docs, or logs, automatic window equalization can constantly resize it.