Meet the arglist
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.
I’m running a Core Vim masterclass online, on Monday, June 3rd. Tickets cost £95, but you can get the earlybird discount price of £80 if you buy yours before May 24th. Come and see how Vim can blow your mind, or your money back.
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:
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|
||reverse through argument list|
||advance through argument list|
||go to start of arglist|
||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).
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.