How do I put all visible windows into diff mode and balance their sizes in Vim?
:windo diffthis | wincmd =<CR>
When you already have multiple related buffers open, you can enter diff mode across all visible windows in one shot and then normalize layout width/height immed
category:
buffers-windows
tags:
#buffers
#windows
#diff
#ex-commands
How do I wrap an entire line in surrounding characters using vim-surround?
The yss{char} mapping from the vim-surround plugin surrounds the entire current line (ignoring leading whitespace) with the chosen delimiter.
category:
plugins
tags:
#plugins
#editing
#surround
#text-objects
How do I count the words, lines, and characters in just my visual selection?
In visual mode, pressing g reports detailed statistics for the selected text only — word count, character count, and byte count.
category:
visual-mode
tags:
#visual-mode
#editing
#navigation
How do I save only real file buffers when running bufdo across many open buffers?
:bufdo if &buftype ==# '' | update | endif
bufdo is powerful for multi-buffer automation, but a naive write pass can error on special buffers (help, terminal, quickfix, prompts).
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
#automation
#workflow
How do I make Vim's diff mode produce cleaner, more readable diffs?
:set diffopt+=algorithm:patience,indent-heuristic
By default, Vim uses a basic longest-common-subsequence diff algorithm that can produce noisy, hard-to-read diffs.
category:
config
tags:
#config
#editing
#ex-commands
How do I refer to all files in the argument list at once in an Ex command?
The ## special token expands to the names of all files currently in Vim's argument list.
category:
command-line
tags:
#command-line
#buffers
#ex-commands
#search
How do I make mappings feel snappier without breaking key-code timing?
:set timeout timeoutlen=400 ttimeoutlen=30
If custom mappings feel laggy, the issue is often timeout tuning rather than mapping design.
category:
config
tags:
#config
#mappings
#performance
#command-line
#insert-mode
How do I sort lines numerically so that 10 sorts after 2 rather than before it?
By default, :sort in Vim uses lexicographic (alphabetical) ordering, so "10" sorts before "2" because "1" sort n — sort selected lines by the leading number,
category:
visual-mode
tags:
#visual-mode
#ex-commands
#editing
How do I search backward for the word under the cursor?
The # command searches backward for the exact word under the cursor, jumping to the previous occurrence.
category:
search
tags:
#search
#navigation
#normal-mode
How do I make the = operator use an external formatter instead of Vim's built-in indentation?
The equalprg option replaces Vim's built-in = indentation operator with any external formatting program.
category:
config
tags:
#config
#indentation
#formatting
#ex-commands
How do I zero-pad numbers with :substitute using an expression replacement?
:%s/\v(\d+)/\=printf('%04d', submatch(1))/g<CR>
When you need to normalize IDs, ticket numbers, or sequence values, :substitute can do more than plain text replacement.
category:
command-line
tags:
#command-line
#substitute
#regex
#formatting
#ex-commands
How do I use Vim tabs as separate workspaces with different working directories?
:tabnew | lcd /path/to/project
Vim's :lcd (local change directory) sets the working directory per window.
category:
buffers-windows
tags:
#buffers
#windows
#tabs
#workflow
#project-management
How do I make Vim diff produce cleaner hunks and avoid hidden buffer errors?
: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.
category:
config
tags:
#config
#diff
#workflow
#options
How do I change existing surrounding quotes to parentheses with vim-surround?
The cs operator in vim-surround (change surrounding) swaps one pair of delimiters for another without touching the content inside.
category:
plugins
tags:
#plugins
#editing
#surround
#text-objects
How do I make % jump between HTML tags and block-level keywords like if/end?
The matchit plugin ships with Vim and Neovim but is not enabled by default.
category:
plugins
tags:
#navigation
#plugins
#text-objects
#editing
How do I show both the absolute line number on the current line and relative numbers on all other lines?
:set number relativenumber
Enabling both number and relativenumber simultaneously activates hybrid line numbering: the current line displays its true absolute line number while every othe
category:
config
tags:
#config
#navigation
#normal-mode
#editing
How do I make Vim's search stop at the end of the file instead of wrapping back to the top?
By default Vim's wrapscan option is enabled, which causes / and ? searches to wrap silently from the end of the file back to the beginning (and vice versa).
category:
config
tags:
#search
#config
#options
How do I move partial command feedback into the statusline instead of the last screen line?
:set showcmdloc=statusline
When you chain operators and motions, showcmd feedback is critical, but the default bottom-line location can fight with command messages and prompts.
category:
command-line
tags:
#command-line
#ui
#statusline
#config
How do I make gf find files even when the import path omits the file extension?
:set suffixesadd+=.js,.ts,.py
In many programming languages, import statements reference modules without file extensions (e.
category:
navigation
tags:
#navigation
#config
#editing
How do I quickly change the text between any pair of delimiters?
ci" / ci( / ci{ / ci[ / ci` / ci'
The ci{delimiter} family of commands changes the text inside any matching pair of delimiters.
category:
editing
tags:
#editing
#text-objects
#change
#delimiters
#normal-mode