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.
48 results for ":argdo"
##
The ## special token expands to the names of all files currently in Vim's argument list.
:bufdo command
The :bufdo command executes an Ex command on every buffer in the buffer list.
:update
The :update command (abbreviated :up) writes the buffer to disk only if it has been modified since the last save.
:args *.py
Use :args *.
:silent! %normal @q
Combining :silent!, the % range, and :normal @q gives you a powerful pattern for applying a macro across an entire file while gracefully skipping lines that don
:s/pattern/replace/flags
The substitute command supports several flags that modify its behavior.
: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.
macros #macros #location-list #refactoring #command-line #normal-mode
: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.
: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.
:%s/pattern/replacement/ge
The e flag on :substitute silences the "Pattern not found" error that Vim normally reports when a substitution has no matches.
:normal! @q
Recorded macros can become fragile when your config defines mappings that shadow built-in keys.
:history :
When you work with long substitution pipelines or multi-part Ex commands, digging through all history (:history) adds noise.
:cdo normal! @q
When a refactor target spans many files but only specific matches matter, running a macro globally is risky.
:windo {cmd}
:windo {cmd} executes an Ex command in every window in the current tab page, cycling through each one and applying the command before returning focus to the ori
buffers-windows #windows #buffers #ex-commands #buffers-windows
:next
When Vim is opened with multiple files (e.
command-line #buffers-windows #ex-commands #navigation #editing
:sp +/{pattern} {file}
The +{cmd} syntax lets you run an Ex command immediately after a file is opened.
:set lazyredraw
When Vim runs a macro or an :argdo / :bufdo loop, it redraws the screen after every command by default.
:bufdo %s/old/new/ge | update
The :bufdo command executes an Ex command in every loaded buffer.
buffers-windows #buffers #ex-commands #editing #substitution
:cdo normal! @a | update
When you already have a precise quickfix list, :cdo is one of the safest ways to run a macro only where it matters.
:bufdo {cmd}
:bufdo executes an Ex command in each open buffer in sequence, cycling through every buffer in the buffer list.