How do I run a substitution across all files in the argument list?
:argdo %s/old/new/g | update
The :argdo command runs an Ex command on every file in the argument list (the files you opened Vim with, or added via :argadd).
Search Vim Tricks
Searching...:argdo %s/old/new/g | update
The :argdo command runs an Ex command on every file in the argument list (the files you opened Vim with, or added via :argadd).
<C-v>$
In visual block mode, pressing $ extends the selection to the end of every line, even when lines have different lengths.
g<C-a> in visual mode
When you have multiple lines with the same number and want to turn them into a sequence (1, 2, 3.
/\zs and \ze
The \zs and \ze atoms let you define where the actual match starts and ends within a larger pattern.
gcc / gc{motion}
The vim-commentary plugin by Tim Pope provides a simple, operator-based way to comment and uncomment code.
qa Yp <C-a> q
By combining a macro with (increment number), you can quickly generate numbered sequences.
/pattern1/;/pattern2/
Vim's search offsets allow chaining two patterns together with a semicolon.
:set iskeyword+={char}
iskeyword defines which characters are considered word characters in Vim.
<C-r><C-o>{register}
The standard {reg} pastes register contents in Insert mode, but Vim may auto-indent multi-line text to match the current indentation level — sometimes manglin
<C-i>
Every time you make a "jump" — using G, /, %, :tag, , or similar commands — Vim records your position in the jump list.
:normal! {keys}
:normal {keys} executes keystrokes as if typed in Normal mode — but it respects your custom mappings and abbreviations.
:%s/\s\+/ /g
The pattern \s\+ matches one or more whitespace characters (spaces, tabs).
:resize +N / :resize -N
:resize adjusts the height of the current window by a relative or absolute amount.
:verbose set {option}?
:verbose set {option}? shows the current value of an option and reports exactly which file set it last — the full path and line number.
gl{motion}{char}
vim-lion (by Tom McDonald) adds gl and gL as alignment operators.
:'<,'>s/pattern/replacement/g
When you make a visual selection and then type :, Vim automatically inserts ' as the range — the marks for the start and end of the last visual selection.
]q and [q
The vim-unimpaired plugin by Tim Pope provides pairs of bracket mappings for common navigation and toggling tasks.
:set breakindent
When wrap is enabled, long lines wrap to the next screen row starting at column 1 by default, which makes indented code look messy.
:sb {buffer}
The :sb (short for :sbuffer) command opens a buffer that is already loaded in Vim in a new horizontal split window.
When recording a macro, you can execute another macro inside it by pressing @b (or any register) during the recording.