1

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

Thanks!

6

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*
-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*
-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}

Example:

  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 '15 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. – user3813057 Apr 15 '15 at 22:20
  • 1
    @user3813057 you can use the tab navigation commands. For example :help gt and :help gT – akshay Apr 15 '15 at 22:45

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