2

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!

user3813057
  • 1,451
  • 3
  • 17
  • 26

1 Answers1

7

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
akshay
  • 6,497
  • 37
  • 43