It is trivial to open multiple files in vim using something like vim file1.txt file2.txt
. That will open each file for editing. Sometimes though, the file list needs to be generated dynamically. For that, we can pass a file list to vim using:
vim `<command`>`
The above will open each of the files listed in the output of <command>
in a separate buffer. From there, edit, close, and move around buffers as you normally would. For example, let's open all the files in directory dir1
:
vim `find dir1 -type f`
Or, open all the modified files as reported by git:
vim `git ls-files --modified`