Jacobo de Vera
Jacobo de Vera

Reputation: 1933

How can I split horizontally across several vertically split windows in Vim?

Basically, I want to go from 1) to 2) I usually do this by splitting horizontally first and then vertically, but as I want this to do three-way diffs, it is much handier to start vim by running:

$ vimdiff file1 file2 file3

And then doing something to open the split window below.

1)
    +----+----+----+
    ¦    ¦    ¦    ¦
    ¦ f1 ¦ f2 ¦ f3 ¦
    ¦    ¦    ¦    ¦
    +----+----+----+

2)
    +----+----+----+
    ¦    ¦    ¦    ¦
    ¦ f1 ¦ f2 ¦ f3 ¦
    +----+----+----+
    ¦      f4      ¦
    +--------------+

Does anyone know of a way to this?

Upvotes: 28

Views: 4324

Answers (2)

DrAl
DrAl

Reputation: 72606

In addition to Hasturkun's excellent answer, you may find some of the Ctrl-W commands quite useful:

These are Ctrl-W followed by (capital) H, J, K or L. These move the current window to the extreme left, bottom, top or right respectively. So to go from your 1 to 2, as an alternative to using :botright, you could do a normal :sp or :vsp and then do Ctrl-W J and the window will be moved to the bottom.

:help CTRL-W_H
:help CTRL-W_J
:help CTRL-W_K
:help CTRL-W_L

Upvotes: 20

Hasturkun
Hasturkun

Reputation: 36402

use :botright split or :bo sp, it does what you want

Upvotes: 43

Related Questions