Coming soon: Peer to Peer - watch how experts solve tech problems.

Learn more

Coming soon: Peer to Peer - watch how experts solve tech problems.

Meet the arglist

#41

Run time:

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.

Shownotes

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

Comments

Level-up your Vim

Training

Boost your productivity with a Vim training class. Join a public class, or book a private session for your team.

Drew hosted a private Vim session for the shopify team that was one of the best workshops I have ever attended.

John Duff, Director of Engineering at Shopify

Publications

Make yourself a faster and more efficient developer with the help of these publications, including Practical Vim (Pragmatic Bookshelf 2012), which has over 50 five-star reviews on Amazon.

After reading it, I've switched to vim as my default editor on a daily basis with no regrets. ★★★★★

Javier Collado

Learn to use Vim efficiently in your Ruby projects

In association with Thoughtbot, one of the most well respected Rails consultancies in the world, I've produced a series of screencasts on how to make navigating your Ruby projects with Vim ultra-efficient. Along the way, you’ll also learn how to make Ruby blocks a first-class text object in Vim. This lets you edit Ruby code at a higher level of abstraction. Available to buy from Thoughtbot..