36

I know how to split windows in vim, but it's possible to open multiple files using vim in split mode (at startup) from the command line?

In example:

vim file1 file2 file3

or:

vim *.cpp
39

You can use the option -o to open the files in horizontal splits or -O to open vertical splits. The following commands open a window for each file specified:

vim -o *.cpp
vim -O foo bar baz

You can tell Vim the maximum number of windows to open by putting an integer after o or O options, the following example will open at most two windows no matter how many file matches, you will see the first two file specified on the command line, the rest will remain hidden:

vim -o2 *.cpp

See :help -o for all the details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.