How do I load shell command output into quickfix without running :grep?
:cgetexpr systemlist('rg --vimgrep TODO')
When you already have a shell command that emits file:line:col:message records, :cgetexpr is a fast way to populate quickfix directly.
:cgetexpr systemlist('rg --vimgrep TODO')
When you already have a shell command that emits file:line:col:message records, :cgetexpr is a fast way to populate quickfix directly.
: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
command-line #command-line #ex-commands #editing #search #formatting
: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.
:argdo %s/foo/bar/ge | update
Bulk replacements across many files are risky when every buffer gets written unconditionally.
: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.
command-line #command-line #ex-commands #editing #normal-mode
:argdo if search('\s\+$', 'nw') | echo expand('%') | endif
Before running destructive cleanup across many files, it helps to know which files will actually change.
command-line #command-line #search #whitespace #arglist #refactoring
:lockmarks keepjumps keeppatterns %s/foo/bar/ge
Large substitutions are efficient, but they often leave side effects: your last search changes, your jumplist gets noisy, and marks can shift in ways that break
command-line #command-line #editing #substitution #navigation
:cdo keepjumps keeppatterns %s/\<OldSymbol\>/NewSymbol/ge | update
When you run :cdo over a large quickfix list, Vim can leave your jump list noisy and your last search pattern overwritten.
command-line #quickfix #ex-commands #search #editing #refactoring
:cdo keeppatterns s/\<foo\>/bar/gec | update
When quickfix already contains precise targets, :cdo gives you a safer multi-file replace loop than broad project substitutions.
command-line #command-line #quickfix #substitute #refactoring
:execute "normal! gg=G"<CR>
:execute lets you build and run Ex commands dynamically, which is critical when a command depends on variables, conditionals, or string composition.
command-line #command-line #ex-commands #normal-mode #automation
:history /
Power users tend to run long, composable searches during refactors, but the default / and ? history navigation can be noisy when command history and search hist
:smagic/\vfoo.+/bar/
If you prefer very-magic regex syntax but don't want to change global settings, :smagic is a targeted solution.
%:S
When you build shell commands from Vim, file paths with spaces or special characters can break the command unless properly escaped.
command-line #command-line #filename-modifiers #shell #expansion
:argdedupe
If you build an arglist incrementally (:args, :argadd, glob expansions), duplicates can sneak in and make :argdo workflows slower or confusing.
command-line #command-line #arglist #batch-editing #workflow
:/BEGIN/,/END/-1s/\s\+$//
When you need to clean or refactor block-like regions, Ex ranges can target lines between two search patterns without selecting text manually.
command-line #command-line #ex-commands #ranges #search #editing
:verbose nmap <lhs>
When key behavior is inconsistent, the root cause is usually mapping precedence.
command-line #command-line #mappings #debugging #config #normal-mode
: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.
:undojoin | normal! A;<CR>
When you automate edits from Ex commands, Vim usually creates a separate undo entry for each change.
:<C-f>
Long Ex commands are easy to mistype when you edit inline on a single command line.
:cexpr system('rg --vimgrep "TODO"')
When you already know you want an external search tool, :cexpr lets you import results directly into quickfix without opening a terminal buffer or shelling out