Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To switch from vertical split to horizontal split fast in Vim

Tags:

vim

split

How can you switch your current windows from horizontal split to vertical split and vice versa in Vim?

I did that a moment ago by accident but I cannot find the key again.

like image 485
Léo Léopold Hertz 준영 Avatar asked Aug 13 '09 01:08

Léo Léopold Hertz 준영


People also ask

How do you change from vertical to horizontal in Vim?

To change your split orientation use the command that prepends all split commands: ctrl-w followed by either K or H: ctrl-w H – Change horizontal splits to vertical. ctrl-w K – Change vertical splits to horizontal.

How do I switch between splits 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.


1 Answers

Vim mailing list says (re-formatted for better readability):

To change two vertically split windows to horizonally split

Ctrl-w t Ctrl-w K

Horizontally to vertically:

Ctrl-w t Ctrl-w H

Explanations:

Ctrl-w t makes the first (topleft) window current

Ctrl-w K moves the current window to full-width at the very top

Ctrl-w H moves the current window to full-height at far left

Note that the t is lowercase, and the K and H are uppercase.

Also, with only two windows, it seems like you can drop the Ctrl-w t part because if you're already in one of only two windows, what's the point of making it current?

like image 76
Mark Rushakoff Avatar answered Oct 05 '22 08:10

Mark Rushakoff