Subscribe for free with iTunes, Twitter, or RSS (Ogg or Quicktime).


Populating the arglist


The arglist wouldn’t be much use if we had to quit and relaunch Vim every time we wanted to change its contents. In this episode, we’ll learn how to set the contents of the arglist using the :args command, which can receive filepaths, globs, or even backtick expressions.


OGG 6.2 MB

Quicktime 10.6 MB

When run with no arguments, the :args command reveals the contents of the arglist. But when a valid {arglist} is passed to the :args command it sets the contents of the arglist:

Ex command effect
:args show the contents of the arglist
:args {arglist} set the contents of the arglist

The {arglist} could be:

  1. one or more filepaths (separated by whitespace)
  2. a wildcard
  3. a backtick expression
  4. a combination of the above

As a general rule: anything that you can provide as an argument to the Vim executable at the commandline can also be supplied as an argument to the :args command.

Backtick expression are particularly powerful. In the video, I use the simple example of running :args `cat .toc` to use the contents of a plaintext file to populate the arglist, but we could put anything inside that backtick expression. So long as the subshell returns a list of filepaths, then Vim will consider it as valid input. For example, you could use the output of find or grep, or even a shell script of your own.

Further reading