How do I restrict keyword completion to current buffer, windows, buffers, and tags for predictable results?
Default keyword completion can feel noisy in large projects because Vim may scan extra sources you do not care about in the moment.
category:
config
tags:
#config
#completion
#insert-mode
#performance
#tags
How do I get exact current and total counts for my last search pattern in Vim?
:echo searchcount({'recompute': 1})
Vim can show match counts for your last search, but in large files or after big edits the cached values may lag.
category:
search
tags:
#search
#command-line
#automation
#statusline
#diagnostics
How do I repeatedly run a macro while a pattern is still found in the buffer?
:while search('TODO') | normal! @q | endwhile
A fixed count like 100@q is brittle: sometimes your macro needs 12 passes, sometimes 300, and over-running can corrupt already-processed text.
category:
macros
tags:
#macros
#automation
#search
#normal-mode
#ex-commands
How do I open a scratch split that is not listed and disappears when I close it?
:vnew | setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
For quick throwaway notes, command output cleanup, or temporary edits, a normal buffer is noisy: it appears in :ls, can prompt you to save, and may leave swap a
category:
buffers-windows
tags:
#buffers-windows
#buffers
#windows
#scratch
#workflow
How do I force a register to be linewise before I put it in Vim?
:call setreg('a', @a, 'V')
When you paste from a register, Vim uses that register's stored type: characterwise, linewise, or blockwise.
category:
registers
tags:
#registers
#editing
#command-line
#setreg
How do I open a vertical diff between index and working tree for the current file in vim-fugitive?
When reviewing staged versus unstaged changes, jumping between terminal git commands and editor windows is slow.
category:
plugins
tags:
#plugins
#git
#diff
#fugitive
#review
How do I append the current filename to a named register from Ex command-line?
:let @a .= expand('%:t') . "\n"
Named registers are not just for yanks and deletes.
category:
registers
tags:
#registers
#command-line
#automation
#editing
How do I keep file ownership and metadata stable when Vim writes through symlinks?
When Vim saves a file, it may use a rename-style write strategy that can replace the original inode.
category:
config
tags:
#config
#files
#write
#options
How do I remove trailing whitespace across all open buffers and save only changed files?
:bufdo keeppatterns %s/\s\+$//e | update
If you keep many files open during a refactor, cleaning trailing whitespace one buffer at a time is slow and error-prone.
category:
buffers-windows
tags:
#buffers
#command-line
#editing
#whitespace
How do I search a project without overwriting the global quickfix list?
:lvimgrep /pattern/gj **/*.js | lopen
When you already rely on the global quickfix list for compiler errors or another search, running :vimgrep can wipe that context.
category:
search
tags:
#search
#command-line
#quickfix
#navigation
How do I preview a fuzzy tag match in the preview window without immediately switching buffers?
When a symbol name is ambiguous, jumping directly with :tag can bounce you around the codebase and disrupt your working context.
category:
navigation
tags:
#navigation
#tags
#windows
#code-navigation
#command-line
How do I create a Visual selection for the previous search match instead of the next one?
Most users know gn for selecting the next search match, but its counterpart gN is the real power move when you need to work backward through matches.
category:
visual-mode
tags:
#visual-mode
#search
#motions
#editing
#normal-mode
How do I execute a recorded macro once in each currently open window?
When you split a file into multiple windows or keep several related buffers visible, repeating the same small cleanup in each one can be tedious.
category:
macros
tags:
#macros
#windows
#normal-mode
#ex-commands
#automation
How do I make the fold column appear only when needed and cap its width?
If you use folds heavily, a fixed fold column is a tradeoff: foldcolumn=0 hides useful fold cues, while a constant width wastes horizontal space in files that b
category:
config
tags:
#config
#folding
#ui
#windows
How do I remove trailing whitespace without clobbering @/ or showing no-match errors?
:silent keeppatterns %s/\s\+$//e
Trailing whitespace cleanup is a common housekeeping step, but a plain substitution can leave side effects: it can overwrite your last search pattern (@/) and t
category:
command-line
tags:
#command-line
#ex-commands
#editing
#search
#formatting
How do I move the current split into a new tab and immediately jump back to the previous tab?
When a split temporarily becomes the center of attention, promoting it to its own tab can reduce layout noise.
category:
buffers-windows
tags:
#buffers
#windows
#tabs
#navigation
How do I uppercase only the text inside braces using a visual text object?
When editing structured text, you often need to transform content inside delimiters without touching the delimiters themselves.
category:
visual-mode
tags:
#visual-mode
#text-objects
#editing
#motions
How do I uppercase only the current search match using gn as a motion?
gn is often treated as a visual selection command, but it is more powerful when used as a motion target for operators.
category:
search
tags:
#search
#motions
#editing
#normal-mode
How do I record a macro that uppercases a word and advances so I can replay it across words?
Macros are most powerful when they encode both the edit and the movement to the next target.
category:
macros
tags:
#macros
#editing
#motions
#normal-mode
How do I uppercase a word and then jump back to my exact original cursor position?
When you run an operator like gUiw, Vim can leave your cursor in a slightly different place than where you started.
category:
editing
tags:
#editing
#marks
#motions
#normal-mode