How do I repeat my last substitution across the entire file?
g&
The g& command repeats the last substitute command across the entire file.
2125 results for "i" a""
g&
The g& command repeats the last substitute command across the entire file.
:%s/old/new/gc
Adding the c flag to a substitute command makes Vim pause at every match and ask you whether to replace it.
:mksession
:mksession saves a snapshot of the current Vim session — all open buffers, window splits, tab pages, cursor positions, and folds — to a file called Session.
zf / zo / zc / za
Vim's folding system lets you collapse blocks of code into a single line, hiding the details so you can focus on the structure.
editing #editing #folding #navigation #normal-mode #productivity
gj and gk
When wrap is enabled, long lines wrap across multiple screen lines.
:'<,'>s/^/\=line('.')-line("'<")+1 . '. '/
When you need quick numbered steps, logs, or checklist entries, this pattern adds numbers only to the lines you selected, not the whole buffer.
g+
Vim's undo history is a tree, not a linear stack.
vim-sleuth
The vim-sleuth plugin by Tim Pope automatically detects the indentation style (tabs vs spaces) and width used in a file and sets shiftwidth, expandtab, tabstop,
:InspectTree
Opens an interactive split window showing the treesitter parse tree for the current buffer.
<C-w>h / <C-w>j / <C-w>k / <C-w>l
How it works Vim lets you navigate between split windows using followed by a direction key.
z.
Vim has two flavors of each screen-repositioning command: one that only moves the view and one that also repositions the cursor.
:e $MYVIMRC
The :e $MYVIMRC command opens your Vim or Neovim configuration file instantly, no matter where it lives.
/\S\zs\s\+$
A plain trailing-whitespace search like /\s\+$ also matches fully blank lines, which is noisy when you only want accidental spaces after real content.
g;zvzz
Jumping through the changelist with g; is useful, but in real files the destination can land inside a closed fold or off-center on screen, which slows review.
:Git
The vim-fugitive plugin by Tim Pope provides an interactive Git status window that lets you stage, unstage, diff, and commit files entirely from within Vim.
<C-q> (Telescope)
While inside any Telescope picker, pressing sends all current results to the quickfix list and closes the picker.
:packadd cfilter | Cfilter /ERROR/
Quickfix lists can get noisy in large projects, especially when one grep or compiler run mixes several classes of issues.
/[[:digit:][:upper:]]
Vim supports POSIX character classes inside bracket expressions, providing a portable and readable way to match categories of characters.
s{char}{char}
The vim-sneak plugin by Justin Keyes provides a motion that lets you jump to any visible location by typing just two characters.
:cnoreabbrev {lhs} {rhs}
:cnoreabbrev defines a non-recursive command-line abbreviation — like noremap but for Ex commands.