How do I reindent the previous visual selection and keep it selected?
gv=gv
When you are iterating on indentation, repeating selection steps is wasted motion.
visual-mode #visual-mode #indentation #editing #formatting #workflow
Search Vim Tricks
Searching...gv=gv
When you are iterating on indentation, repeating selection steps is wasted motion.
visual-mode #visual-mode #indentation #editing #formatting #workflow
:NoMatchParen
Vim's built-in matchparen plugin highlights matching delimiters as your cursor moves.
plugins #plugins #performance #editing #autocommands #delimiters
:set shortmess+=c
Insert-mode completion can spam the command line with status text like "match 1 of N" and related prompts.
config #config #completion #command-line #options #insert-mode
:let @a = getreg('0')
When you want to preserve a valuable yank before doing destructive edits, copying register 0 into a named register is safer than re-yanking text.
registers #registers #yanking #editing #command-line #refactoring
:verbose nmap <lhs>
When key behavior is inconsistent, the root cause is usually mapping precedence.
command-line #command-line #mappings #debugging #config #normal-mode
:s/\v(\S+)\s*=\s*(.*)/\=printf('%-20s = %s', submatch(1), submatch(2))/
When a line contains uneven key = value spacing, quick manual fixes are easy to get wrong.
:let @/='\V'.escape(@", '\\')
When you yank text that contains regex characters like .
:set diffopt+=algorithm:histogram,hiddenoff
Default diff behavior is fine for small changes, but larger refactors often produce noisy hunks and annoying warnings about hidden buffers.
qqgUiwjq2@q
Macros are strongest when the edit pattern is stable but too awkward for a one-liner substitute.
:let @a=@1
When you delete full lines repeatedly, Vim rotates those deletions through numbered registers.
:set cedit=<C-y>
Vim's command-line window is invaluable for editing long : commands, search patterns, and complex substitutions with normal-mode tools.
:set sessionoptions+=globals
By default, :mksession restores windows, buffers, and many editor states, but it skips most global variables.
:s/\%#\k\+/REPL/
Most substitutions operate on broad ranges, but sometimes you want a precise edit anchored to where your cursor is right now.
:lvimgrep /TODO/j **/* | lopen
When you are working in split-heavy sessions, global quickfix results can become noisy because every window shares the same list.
:argdo %s/\s\+$//e | update
When you need to clean up many files at once, :argdo lets you run the same command on every buffer in your argument list.
:vimgrepadd /pattern/j **/*<CR>
When you are investigating code, you often need to collect several related patterns before deciding what to edit.
g<C-x>
Most people know decrements one number under the cursor, but g in Visual mode performs a sequential decrement across the selection.
:tab sbuffer {bufnr}<CR>
If a file is already loaded as a buffer, reopening it with :tabedit can trigger another read and may lose the exact in-memory context you want.
:'a,'bnormal! @q<CR>
When you need to replay a macro on a precise region, selecting lines manually can be slow and error-prone.
:undojoin | normal! A;<CR>
When you automate edits from Ex commands, Vim usually creates a separate undo entry for each change.