To switch from vertical split to horizontal split fast in Vim

 
up vote293down votefavorite

147

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.

share|improve this question  
 
asked Aug 13 '09 at 1:38

Masi
21.8k77266454

 
    
perhaps dwm.vim plugin will be kinda useful –  ДМИТРИЙ МАЛИКОВ Jan 12 '13 at 12:43
add a comment | 

5 Answers 5

up vote385down voteaccepted 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?
share|improve this answer

Vinod
1,30261025

answered Aug 13 '09 at 1:48

Mark Rushakoff
102k16234298

 
3  
So if you have two windows split horizontally, and you are in the lower window, you just use ^WL. –  too much php Aug 13 '09 at 2:17
1  
+1 - Thanks! Super-easy to understand! –  Topher Fangio Jan 17 '12 at 14:26
4  
.... The power... My vim-fu doubled today, thank you. There are a ton of interesting ^w commands (b, w, etc) –  Alex Hart Dec 7 '12 at 14:10
    
somehow doesn't work for me.. =/ –  holms Feb 28 '13 at 9:07
1  
@Eno Works fine for me. Just toggle your NERDTree panel closed before 'rotating' the splits, then toggle it back open. :NERDTreeToggle (I have it mapped to a function key for convenience). –  Lambart Mar 26 at 19:34
 | show 2 more comments
 
up vote97down vote ^w followed by capital H,J,K or L will move the current window to the far left,bottom,top or right respectively like normal cursor navigation.

The lower case equivalents move focus instead of moving the window.
share|improve this answer

F.C.
3,36331742

answered Nov 2 '11 at 14:41

respectTheCode
7,09993852

 
1  
Wow, cool! Thanks! :-) –  infous Feb 6 at 8:46
    
it's much better since users use hjkl to move between buffers. –  Afshin Mehrabani Aug 22 at 6:07
add a comment | 
up vote15down vote In VIM, take a look at the following to see different alternatives for what you might have done:

:help opening-window

For instance:

Ctrl-W s
Ctrl-W o
Ctrl-W v
Ctrl-W o
Ctrl-W s
...
share|improve this answer

Vinod
1,30261025

answered Aug 13 '09 at 2:02

Anon
3,5981016

 
    
The command ^W-o is great! I did not know it. –  Masi Aug 13 '09 at 2:20
add a comment | 
up vote6down vote The following ex commands will (re-)split any number of windows:
  • To split vertically (e.g. make vertical dividers between windows), type :vertical ball
  • To split horizontally, type :ball

If there are hidden buffers, issuing these commands will also make the hidden buffers visible.
share|improve this answer
answered Apr 29 at 21:45

Mark
365310

 
   
add a comment | 
up vote2down vote When you have two or more windows open horizontally or vertically and want to switch them all to the other orientation, you can use the following:

(switch to horizontal)

:windo wincmd K

(switch to vertical)

:windo wincmd H

It's effectively going to each window individually and using ^WK or ^WH.
share|improve this answer
answered Oct 22 at 19:31

Steve
930512

 
   
add a comment | 

protected by Masi Nov 24 '13 at 7:55

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?