I'm using Ubuntu system. I have files: A.txt, B.txt, C.txt

I can split window in the following way:

vim A.txt
:vs B.txt    // after entering into vim
:vs C.txt

Is there any way to achieve the same effect using command line? like vim -option A.txt B.txt C.txt ?

vim A.txt B.txt    doesn't work, it doesn't show the files simultaneously
vimdiff *.txt     works, but I really don't need the difference shown



1 Answer 1


Vim's -o and -O options will open the files while splitting them horizontally or vertically respectively.

Taken from Vim's help page :help -o and :help -O:

-o[N]       Open N windows, split horizontally.  If [N] is not given,
        one window is opened for every file given as argument.  If
        there is not enough room, only the first few files get a
        window.  If there are more windows than arguments, the last
        few windows will be editing an empty file.
        {not in Vi}

-O[N]       Open N windows, split vertically.  Otherwise it's like -o.
        If both the -o and the -O option are given, the last one on
        the command line determines how the windows will be split.
        {not in Vi}


  1. vim -o A.txt B.txt C.txt will open three horizontal splits for each file.
  2. vim -O A.txt B.txt C.txt will open three vertical splits for each file
  • 1
    Related: Also see Vim's -p option to open each file in different tab pages.
    – akshay
    Apr 15, 2015 at 1:54
  • BTW, how do you switch among tabs when using -p option? I tried ctrl+PageDown, ctrl+tab and ctrl+w. No one works. Apr 15, 2015 at 22:20
  • 1
    @user3813057 you can use the tab navigation commands. For example :help gt and :help gT
    – akshay
    Apr 15, 2015 at 22:45

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