Apply an edit to an argument list
:argdo %s/old/new/ge | update
Example
Normal mode. a.txt and b.txt contain old and will be saved. c.txt is also open.
Before
Argument list: a.txt, b.txt
a.txt and b.txt contain old.
c.txt is open but is not an argument.
- :args a.txt b.txt<CR> Argument list · a.txt, b.txt only
- :args<CR> Review the argument list
- :argdo %s/old/new/ge | update<CR> Replace old throughout a.txt and b.txt; save changes; c.txt unchanged
After
a.txt and b.txt: old becomes new; changes saved
c.txt: unchanged
Details & Vim help
Use the argument list as an explicit batch of files.
Make the scope of a multi-file edit inspectable before applying it.
Glob expansion and the current directory determine scope. update also writes existing unsaved edits in visited buffers. e suppresses missing-pattern errors; other errors can stop the batch.
:argdo visits the argument list. update also saves any other pending edits in those visited buffers.
Try it in Vim
- Run :args *.txt, or supply explicit paths.
- Run :args again to review the expanded list.
- Run :argdo %s/old/new/ge | update when you intend to write changed buffers.