How do I run the same command across all open buffers at once?
:bufdo
When you need to apply the same change to every file you have open in Vim, switching to each buffer manually is tedious and error-prone.
48 results for ":argdo"
:bufdo
When you need to apply the same change to every file you have open in Vim, switching to each buffer manually is tedious and error-prone.
:%Subvert/old/new/g
The vim-abolish plugin by Tim Pope provides the :Subvert command (abbreviated :S), which performs search-and-replace operations that automatically handle every
:call setreg('q', keys, 'c')
The setreg() function writes any string directly into a named register, letting you construct macro keystrokes from Vimscript expressions rather than live recor
Use :s/pat/rep/e flag or :silent! prefix
By default, Vim macros abort on the first error — a failed search, a substitute with no matches, or a movement that can't be performed.
:s/pattern/replacement/e
The e flag in Vim's :substitute command silently ignores the "E486: Pattern not found" error when the pattern does not match anything.
:wn
:wn (short for :wnext) writes the current buffer to disk and immediately advances to the next file in the argument list.
:bufdo normal @a
The :bufdo command executes an Ex command in every open buffer, and when combined with :normal @a, it replays macro a across all of them.
macros #macros #buffers #ex-commands #automation #productivity
:set hidden
By default, Vim refuses to let you switch away from a buffer that has unsaved changes, forcing you to save or discard with :w or :e! before moving on.