Using the vim split command from the command line to get 4 quarter splits

Solution 1:

You can use the 'wincmd' command to move to different windows as if you're pressing CTRL+W.

vim file4 -c 'split file2' -c 'vsplit file1' -c 'wincmd j' -c 'vsplit file3'

This will arrange the files as:

file1   file2
file3   file4

How it works: opens file4. Splits horizontally so file2 is above it. Splits vertically so file1 is to the left, moves to the next window (file1) and vertically splits again.

Solution 2:

I wrote a script using this information that automatically splits the screen as I wish:

vimsp.py file1 file2 / file3

Results in

-----------
|f1  |f2  |
|    |    |
-----------
|file 3   |
|         |
-----------

Also, putting / in front of all files makes them all split vertically instead:

vimsp.py / file1 file2 file3

-------------
|file 1     |
-------------
|file 2     |
-------------
|file 3     |
-------------

https://gist.github.com/1376956