How do I run one substitution in nomagic mode so most regex characters are literal?
:snomagic /foo.\+/bar/<CR>
When a pattern is mostly literal text with just a little regex, default magic mode can force extra escaping and make substitutions harder to read.
category:
command-line
tags:
#command-line
#search
#regex
#editing
How do I trim trailing whitespace in a file without polluting jumplist or search history?
:keepjumps keeppatterns %s/\s\+$//e<CR>
Bulk whitespace cleanup is common, but a plain substitution can leave side effects: your last search pattern changes and jump navigation gets noisy.
category:
editing
tags:
#editing
#command-line
#search
#formatting
How do I preview a macro register with escaped keycodes before executing it?
Macro failures are often caused by hidden control keys like , , or tabs that are hard to see in raw register output.
category:
registers
tags:
#registers
#macros
#debugging
#command-line
How do I run a normal-mode append on only matching lines inside a visual selection?
:'<,'>g/let /normal! A;<CR>
When you need a structural edit in part of a file, Visual mode ranges combine well with :global and :normal!.
category:
visual-mode
tags:
#visual-mode
#command-line
#ex-commands
#editing
How do I delete through the end of the next search match from the cursor?
When you need to remove text up to a known marker, a plain search motion is often almost right but stops at the start of the match.
category:
navigation
tags:
#navigation
#search
#motions
#editing
How do I tune Vim diff so moved code blocks align more accurately?
:set diffopt+=internal,algorithm:histogram,indent-heuristic
Default diff settings are fine for small edits, but they can produce noisy hunks when code is moved or indentation shifts.
category:
config
tags:
#config
#buffers
#windows
#editing
How do I reselect the previous visual area and convert it to linewise selection?
gv is well known for reselecting the previous visual area, but pairing it with V is a practical upgrade when your next action needs linewise semantics.
category:
visual-mode
tags:
#visual-mode
#navigation
#editing
How do I search forward but place the cursor at the end of the match?
Most users know /pattern, but fewer use search offsets to control where the cursor lands after the match.
category:
search
tags:
#search
#navigation
#normal-mode
How do I rotate split windows forward without reopening any buffers?
When a split layout is correct but the window positions are awkward, you do not need to close and reopen anything.
category:
buffers-windows
tags:
#windows
#buffers
#command-line
#navigation
How do I append more commands to a recorded macro without re-recording it?
When a recorded macro is almost right but missing one repeated step, re-recording from scratch is usually slower and riskier than patching the register directly
category:
macros
tags:
#macros
#registers
#command-line
#normal-mode
How do I run a substitution across the arglist and write only modified files?
:argdo %s/foo/bar/ge | update
Bulk replacements across many files are risky when every buffer gets written unconditionally.
category:
command-line
tags:
#command-line
#arglist
#refactor
#ex-commands
How do I tune Vim diff mode for more readable side-by-side hunks?
:set diffopt+=vertical,algorithm:patience,indent-heuristic
Default diff behavior can look noisy on refactors where blocks move or indentation shifts.
category:
config
tags:
#config
#diff
#review
#buffers-windows
How do I replace the next word with a yanked word without clobbering the unnamed register?
When you are doing repetitive refactors, cw is fast but it overwrites the unnamed register with the replaced text.
category:
registers
tags:
#registers
#editing
#normal-mode
#insert-mode
How do I collapse consecutive duplicate words across a file?
:%s/\v<(\w+)\s+\1>/\1/g\<CR>
OCR cleanup, copy-paste artifacts, and rushed note-taking often produce repeated words like the the or is is.
category:
search
tags:
#search
#regex
#substitute
#ex-commands
How do I append a semicolon to every non-blank line with one Vim command?
:g/[^[:space:]]/normal! A;\<CR>
When you need to patch many lines at once, :g with :normal! is often faster and safer than recording a macro.
category:
command-line
tags:
#command-line
#ex-commands
#editing
#normal-mode
How do I allow block selections past end-of-line while still permitting one-char past EOL cursor movement?
:set virtualedit=block,onemore
virtualedit controls whether the cursor can move to positions that do not yet contain text.
category:
config
tags:
#config
#visual-mode
#blockwise
#editing
#cursor
How do I populate a window-local location list for only the current file using ripgrep output?
:call setloclist(0, [], 'r', {'title': 'TODO current file', 'lines': systemlist('rg --vimgrep TODO ' . shellescape(expand('%:p'))), 'efm': '%f:%l:%c:%m'})
For focused review work, a window-local location list is often better than global quickfix.
category:
buffers-windows
tags:
#buffers
#windows
#location-list
#search
#quickfix
How do I rerun a previous search pattern from history directly on the / prompt?
/\V<C-r>=histget('/', -2)<CR>
If you often alternate between two complex search patterns, opening q/ each time is slow.
category:
search
tags:
#search
#command-line
#history
#regex
#productivity
How do I apply a macro only to files that appear in the current location list?
:lfdo normal! @q | update
When you already have a curated location list, :lfdo lets you apply a change only to those files instead of touching your whole project.
category:
macros
tags:
#macros
#location-list
#refactoring
#command-line
#normal-mode
How can I print only arglist files that still contain trailing whitespace before bulk cleanup?
:argdo if search('\s\+$', 'nw') | echo expand('%') | endif
Before running destructive cleanup across many files, it helps to know which files will actually change.
category:
command-line
tags:
#command-line
#search
#whitespace
#arglist
#refactoring