The argument list *argument-list* *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.
If you have been using vim a while you will be comfortable with the buffer list but often it’s full of random files, terminal sessions, and other none file buffers, this is where arglist comes in. It starts out as list of files that were initially opened when the vim session was launched ex:
nvim ./a.txt ./b.txt ./c.txt
would start vim with three buffers in both arglist and buffer list. You can cycle through the arglist with files via :next, :prev. Further files opened will not be automatically added to the arglist so it’s essentially a clean sub list of the buffer list. Helpful commands include :rew to jump back to the first file you edited this session. Also :all which opens all buffers of the arglist in splits.
Where I find the arglist particularly powerful is for mass file edits. Here is an day to day example:
- get files in questing into the arglist either pipe files to vim or from in vim override initial arglist.
- from cli
$ rg -i 'snippet_typ.*vim' --files-with-matches | xargs nvim
- from inside vim (harder because no autocomplete)
:args `rg -i 'snippet_typ.*vim' --files-with-matches`
- now lets change all the posts front-matter to draft = true
:argdo %s/draft: false/draft: false/g | update
thats it all the files have been modified and saved. Its best to use this kind of thing with version control so during an interactive git add you can verify each modification.
For more complex edits I load files into the list a similar way then make quick manual and move to next file with :wn which also saves.