How do I resize a split window by an exact number of columns or rows using a count in Vim?
Answer
{n}<C-w>>
Explanation
All four window resize mappings accept an optional count prefix that multiplies the resize amount. Instead of tapping <C-w>> ten times to widen a window by 10 columns, you can use 10<C-w>> to do it in one keystroke.
How it works
The four resize keys with count support:
| Command | Effect |
|---|---|
{n}<C-w>> |
Widen current window by N columns |
{n}<C-w>< |
Narrow current window by N columns |
{n}<C-w>+ |
Increase current window height by N rows |
{n}<C-w>- |
Decrease current window height by N rows |
Without a count, each press adjusts by 1. With a count, the adjustment is multiplied.
Example
:vsplit ← open a vertical split
20<C-w>> ← widen current window by 20 columns instantly
For vertical splits, widening the left window with <C-w>> automatically narrows the right window to compensate.
Tips
- Use
<C-w>=to instantly equalize all window sizes after manual resizing - The Ex command alternative is
:resize +N(rows) or:vertical resize +N(columns) - To set an exact width rather than a relative one:
{n}<C-w>|sets the current window to exactly N columns wide - To set an exact height:
{n}<C-w>_sets the current window to exactly N rows tall