3

The help for :args states:

                            *:ar* *:arg* *:args*
:ar[gs]         Print the argument list, with the current file in
                square brackets.

However, it looks like the square brackets are always around the same file.

I open vim like so:

vim --clean lal lil lul

Whichever buffer I look at, :args shows the same result.

:args
[lal] lil lul

Am I misunderstanding something?

I'm running Vim 8.2, patch 1-2249, with xterm-256color.

3
  • 1
    How are you switching buffer? To navigate the argslist, try :next
    – D. Ben Knoble
    Jan 30 at 13:55
  • So indeed, switching to the next argument (with :next) rather than the next buffer (:bnext) makes a difference. I still don't understand why... should I edit?
    – Biggybi
    Jan 30 at 13:59
  • Well, after a few minutes playing around with arglist and buffers, I get that the 'current file' is the 'current file in the arglist' and not 'the file in the current focused buffer'. Which, I guess, helps to manipulate that list. This can be misleading.
    – Biggybi
    Jan 30 at 14:18
3

From :help arglist:

If you give more than one file name when starting Vim, this list is remembered
as the argument list.  You can jump to each file in this list.

Do not confuse this with the buffer list, which you can see with the
|:buffers| command.  The argument list was already present in Vi, the buffer
list is new in Vim.  Every file name in the argument list will also be present
in the buffer list (unless it was deleted with |:bdel| or |:bwipe|).  But it's
common that names in the buffer list are not in the argument list.

Use :next and :prev (or their capitalized variants, and many other commands) to move in the arglist.

There are several good Vimcasts articles & videos on the subject.


One of my favorite tricks involves :vimgrep'ing the arglist using the :-shortcut ## (:help c_##):

vimgrep /pat/ ##
1
  • 1
    This Vimcast series is awesome indeed, I've been using the Vimgrep / arglist trick for a while now, and it's so comfortable (on small projects at least). Good idea to bring this up into an answer.
    – Biggybi
    Jan 30 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.