In this post, I wll explain how to manipulate multiple files in Vim.
To do it, we use argument list and
By default, argument list store the argument that you pass when starting Vim.
The belows are commands we often use.
For more detail, refer to the help page.(
We can print the argument list by using
$ vim a.txt :args => a.txt
:args with argument, we can clear and define files as argument list.
:args a.txt :args => a.txt
We can pass multiple files as argument.
:args a.txt b.txt :args => a.txt b.txt
We can use *(wild card).
:args *.txt :args => a.txt b.txt c.txt
We can add files by using
:args => a.txt :argadd b.txt :args => a.txt b.txt
To delete files from list, use
:args => a.txt b.txt c.txt :argdelete b.txt :args => a.txt c.txt
Execute ex command to files in argument list
:argdo execute ex command for each file in arguemnt list.
Example below do two operations.
1. Replace abcde with ABCDE
2. Save file by using
:argdo %s/abcde/ABCDE/g | update
We can easily define argument list by using fzf.vim.
For more detail, refer to the link.