How do I resize a split window in Vim?
Answer
<C-w>+ and <C-w>-
Explanation
The <C-w>+ and <C-w>- commands increase or decrease the height of the current split window by one line. For width adjustments, use <C-w>> and <C-w><. These commands give you fine-grained control over your split layout.
How it works
<C-w>+increases the current window's height by 1 line<C-w>-decreases the current window's height by 1 line<C-w>>increases the current window's width by 1 column<C-w><decreases the current window's width by 1 column- Prefix any of these with a count for larger adjustments:
10<C-w>+increases height by 10 lines
Example
You have two horizontal splits, but the top window is too small to see your code:
┌──────────────────┐
│ main.go (5 rows) │
├──────────────────┤
│ test.go (25 rows)│
└──────────────────┘
With the cursor in the main.go window, press 15<C-w>+ to increase its height by 15 lines:
┌──────────────────┐
│ main.go (20 rows)│
├──────────────────┤
│ test.go (10 rows)│
└──────────────────┘
Maximize and equalize
<C-w>_— maximize the current window's height (takes up all available vertical space)<C-w>|— maximize the current window's width (takes up all available horizontal space)<C-w>=— equalize the size of all windows
Ex command alternatives
:resize 20or:res 20— set the window height to exactly 20 lines:resize +5— increase height by 5 lines:resize -5— decrease height by 5 lines:vertical resize 80— set the window width to exactly 80 columns
Tips
- Use
<C-w>=after opening or closing splits to quickly equalize all windows - Use
<C-w>_followed by<C-w>|to temporarily maximize the current window in both dimensions - When working with vertical splits,
<C-w>>and<C-w><are more useful than<C-w>+and<C-w>- - Combine with a count for efficient resizing:
5<C-w>>widens the window by 5 columns - Use
:set winheight=30and:set winwidth=80to set minimum dimensions for the active window — Vim will automatically resize splits as you navigate between them