How do I convert a horizontal split into a vertical split or move a window to the far side of the screen?
Answer
<C-w>H and <C-w>K
Explanation
After opening a split you can dynamically reposition windows using <C-w>H, <C-w>J, <C-w>K, and <C-w>L. These move the current window to the far left, bottom, top, or right of the screen respectively, causing it to span the full screen width or height. This effectively converts a horizontal split into a vertical one (or vice versa) without closing and reopening buffers.
How it works
<C-w>H— Move window to the far left (full-height vertical pane)<C-w>J— Move window to the very bottom (full-width horizontal pane)<C-w>K— Move window to the very top (full-width horizontal pane)<C-w>L— Move window to the far right (full-height vertical pane)
Note the uppercase letters: lowercase <C-w>h/j/k/l simply move the cursor between windows, while uppercase moves the window itself.
Example
You split horizontally with :split file.txt and now have two windows stacked:
┌─────────────┐
│ file.txt │
├─────────────┤
│ current │
└─────────────┘
Press <C-w>L (or <C-w>H) to rotate into a side-by-side vertical split:
┌──────┬──────┐
│ cur │ file │
└──────┴──────┘
Tips
- Works with more than two windows: the moved window takes an entire edge, and remaining windows share the space left over.
- Combine with
<C-w>=to equalize window sizes after repositioning. - To move a window to a new tab entirely, use
<C-w>T.