Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 246
Jacobo de Vera Avatar asked Jul 27 '09 10:07

Jacobo de Vera


People also ask

How do I split screen vertically in Vim?

Splitting Vim Screen Vertically Press the keyboard combination Ctrl + w , followed by the letter 'v' .

How do I switch between split windows in Vim?

To move between splits first press Ctrl-w (I remember this by Control Window, I'm not sure what the official mnemonic is) Then press a directional key to move the cursor to the split you're interested in. Directional key could be the arrows or my preferred home row method.

How do I split my screen horizontally?

Split screen in half The most fundamental way to use split screen in Windows 10 is to drag an open window to the left or right side of the screen. This will automatically 'snap' that window to take up exactly half of the screen.


2 Answers

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

like image 108
Hasturkun Avatar answered Oct 12 '22 14:10

Hasturkun


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 
like image 41
DrAl Avatar answered Oct 12 '22 15:10

DrAl