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

Vimcasts

Meet the arglist

#41

The arglist feature complements Vim’s buffer list. In this episode, we’ll learn a handful of commands for traversing the arglist. We’ll see that it’s useful to think of the arglist as a stable subset of the files in the buffer list.

Download

OGG 6.3 MB

Quicktime 9.6 MB

Vim keeps a record of the filepaths specified on launch in the argument list (or ‘arglist’).

$ vim a.txt b.txt

We can view the contents of this list by running the Ex command (args):

:args
[a.txt] b.txt

The square brackets indicate which of the buffers is active.

If we try to quit Vim, it shows a warning:

:q
E173 1 more file to edit

This is meant as a friendly reminder: we opened more than one file when we launched Vim, so Vim assumes that we want to edit (or at least look at) the contents of each of those files. To close all files and exit without this warning, we can use the command:

:qall

Traversing the arglist

Vim provides four basic Ex commands for traversing the arglist. They are summarized in the following table, along with the mappings provided by the unimpaired plugin:

Ex command unimpaired map effect
:prev[ious] [a reverse through argument list
:next ]a advance through argument list
:first [A go to start of arglist
:last ]A go to end of arglist

The arglist is a stable subset of the buffer list

There’s a lot of overlap between the arglist and the buffer list (which is covered in Vimcast #6 – Working with buffers).

The arglist is a stable subset of the buffer list

You can think of the arglist as being a stable subset of the buffer list. The contents of the buffer list can change often, and sometimes without you realizing it. Whereas the arglist will only change its contents when you give an explicit instruction for it to do so.

Further reading