I want to open 3 files in multiple split mode. For example let's say I have 3 files file1 file2 file3 I want to open file1 & file2 in vertical split mode , and both of the vertical split must be in horizontal split with file3.

vim file1 file2 -O file3 -o

I tried above code , but it overrides the last -O by -o for all 3 files.


1 Answer 1


-o, -O, and -p are mutually exclusive. You can't combine them.

From main.c, command_line_scan():

case 'p':           /* "-p[N]" open N tab pages */
    parmp->window_layout = WIN_TABS;
case 'o':           /* "-o[N]" open N horizontal split windows */
    parmp->window_layout = WIN_HOR;
case 'O':       /* "-O[N]" open N vertical split windows */
    parmp->window_layout = WIN_VER;

and then in create_windows():

parmp->window_count = make_windows(parmp->window_count,
    parmp->window_layout == WIN_VER);

And make_windows() from window.c:

* Make "count" windows on the screen.
* Return actual number of windows on the screen.
* Must be called when there is just one window, filling the whole screen
* (excluding the command line).
make_windows(count, vertical)
    int         count;
    int         vertical UNUSED;  /* split windows vertically if TRUE */
    int         maxcount;
    int         todo; 

As you see, there is no facility to say "split those few windows horizontally, and those few vertically".

The easiest way to do what you want is using -c to send "direct" commands to Vim:

vim main.c -c ':split gui.c' -c ':vsplit window.c'

Which can be abbreviated to:

vim main.c -c 'sp gui.c | vs window.c'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .