How do I make Vim automatically reload files changed outside the editor?
:set autoread | autocmd FocusGained * checktime
When working with Git, build tools, or collaborators, files may change outside Vim.
category:
buffers-windows
tags:
#buffers-windows
#autoread
#file-detection
#external-changes
How do I repeat the last f/t/F/T motion in the opposite direction?
After using f, t, F, or T for single-character motion on a line, Vim lets you repeat that character search without retyping the target.
category:
navigation
tags:
#navigation
#motions
#normal-mode
#editing
How do I include dictionary and spelling words in Vim's insert-mode autocomplete?
Vim's built-in completion ( / ) sources matches from buffers, included files, and tags by default.
category:
editing
tags:
#completion
#insert-mode
#spell
#editing
#config
How do I search non-greedily across multiple lines between two markers?
Multiline searches in Vim often overmatch because .
category:
search
tags:
#search
#regex
#multiline
#patterns
How do I keep the quickfix window height from resizing when splitting?
Quickfix windows are easy to disturb when you open, close, or rebalance other splits.
category:
buffers-windows
tags:
#buffers
#windows
#quickfix
#layout
How do I change the text inside parentheses?
The ci( command deletes everything inside the nearest pair of parentheses and places you in insert mode, ready to type a replacement.
category:
editing
tags:
#editing
#text-objects
#normal-mode
#insert-mode
How do I toggle the case of an entire word in Vim?
The g~iw command toggles the case of every character in the word under the cursor — uppercase letters become lowercase and vice versa.
category:
editing
tags:
#editing
#text-objects
#case
#normal-mode
How do I toggle whether / and ? searches wrap around the file?
wrapscan controls what happens when a / or ? search reaches the end (or beginning) of the file.
category:
search
tags:
#search
#options
#command-line
#navigation
How do I trim trailing whitespace while preserving marks, jumplist, and search state?
:lockmarks keepjumps keeppatterns %s/\s\+$//e
Bulk cleanup commands are easy to automate, but many implementations quietly damage editor state by moving marks, polluting the jumplist, or replacing your last
category:
command-line
tags:
#command-line
#substitute
#automation
#editing
How do I deeply merge two Lua tables in Neovim config using vim.tbl_deep_extend?
vim.tbl_deep_extend('force', defaults, overrides)
vim.
category:
config
tags:
#neovim
#lua
#config
#tables
How do I paste the name of the alternate (previously edited) file into the buffer?
The # register holds the name of the alternate file — the file you were editing just before the current one.
category:
registers
tags:
#registers
#buffers
#navigation
#normal-mode
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 sort lines and remove duplicates in Vim?
The :sort u command sorts all lines in the file and removes duplicate lines in one operation.
category:
command-line
tags:
#command-line
#ex-commands
#editing
#text-manipulation
#sort
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