How do I set a vertical split to an exact column width?
Answer
:vertical resize {N}
Explanation
:vertical resize {N} sets the width of the current window to exactly {N} columns. Without the vertical prefix, :resize adjusts height instead. This is essential for managing side-by-side splits — setting a sidebar to a fixed width, or giving your main editor window more room.
Commands
| Command | Effect |
|---|---|
:vertical resize 80 |
Set current window width to 80 columns |
:vertical resize +10 |
Increase width by 10 columns |
:vertical resize -10 |
Decrease width by 10 columns |
:resize 30 |
Set current window height to 30 rows |
:resize +5 |
Increase height by 5 rows |
<C-w>| |
Maximize window width |
<C-w>= |
Equalize all window sizes |
Keyboard shortcuts
<C-w>>— increase width by 1 (or{N}<C-w>>for N columns)<C-w><— decrease width by 1<C-w>+— increase height by 1<C-w>-— decrease height by 1
Example
Set up a 30-column sidebar for file browsing:
:vsplit
:Explore
:vertical resize 30
Give the main editing window 120 columns:
<C-w>l
:vertical resize 120
Tips
- Map a quick resize:
nnoremap <leader>w :vertical resize 80<CR> :vertical resizeonly affects width;:resizeonly affects height — theverticalprefix is required for width- After
:set equalalways, Vim automatically equalizes windows when one is opened or closed — disable with:set noequalalwaysif you want to keep fixed sizes - In terminal Vim, window sizes are measured in characters;
80columns is a standard terminal width