O'Reilly logo

Mastering Vim by Ruslan Osipov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Operations across files using arglist

Arglist allows you to perform the same operation on multiple files, without having to have them preloaded in buffers first.

Arglist provides a few commands, as follows:

  • :arg defines the arglist.
  • :argdo allows you to execute a command on all the files in the arglist.
  • :args displays the list of files in the arglist.

For example, if we wanted to replace all instances of animal in every Python file (recursively), we would do the following:

:arg **/*.py:argdo %s/\<animal\>/creature/ge | update

This command work as follows:

  • :arg <pattern> adds a set of files matching a pattern to the arglist (each argument in arglist also has a corresponding buffer).
  • **/*.py is a wildcard for every .py file, recursively ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required