VimTrick: Open all files in a directory
Edit a set of files all at once by opening a directory in Vim splits
Recently I was working on a refactor in software project and wanted to get a look at 6 files in a single directory at once. Being able to have all the files on screen at one time would help me get a better look at their contents, compare them, and edit them. I could certainly open each file one by one, calling
:split after each to create a new split in Vim and then replacing the contents of that split with
:e path/to/file. But surely there must be a faster way to open several files in Vim?
There is and it involves using the Vim argument list. To open horizontal splits with every file in a directory, run these two commands in succession:
:args path/to/dir/*- Populates the arglist
:sall- Opens everything in the arglist in splits
Here’s a short screencast showing this in action:
Was this useful? Help us improve!
With your feedback, we can improve VimTricks. Click a link to vote: