How to edit multiple files in Vim

vim

In Vim (more specifically, MacVim), if I've already set the working directory using :cd and I want to open all the *.py files within that directory, is there a way to do so from within Vim? I expected :e *.py would work, but got the E77: Too many file names error. :help edit doesn't seem to offer a way to open multiple files at once, only one.

Best Answer

The command you are looking for is args:

For example:

:args /path_to_dir/*.py

or

:args /path_to_dir/**/*.py

** to match files recursively. (As suggested by @the_velour_fog)

will open all files which has .py extension in the directory.

Once the files are opened use :tab all to put them in individual tabs.

Related Question