How do I make the focused window automatically expand to a minimum size while keeping other windows visible?
Answer
:set winwidth=85 winheight=20
Explanation
Setting winwidth and winheight tells Vim the minimum column width and line height the current focused window must have. When you move focus to another window, Vim automatically resizes it to meet these minimums by shrinking other windows. This creates a smooth "zoom into the active file" effect without fully hiding other splits.
How it works
winwidth— minimum number of columns for the current window (default: 20)winheight— minimum number of lines for the current window (default: 1)winminwidth/winminheight— absolute minimum for non-focused windows (default: 1)
Vim tries to satisfy both constraints when switching windows. Non-focused windows shrink to winminwidth/winminheight to make room.
Example
" In your vimrc:
set winwidth=85
set winheight=20
set winminwidth=10
set winminheight=5
With three vertical splits open, switching to the center window expands it to at least 85 columns. The flanking windows shrink to winminwidth=10 columns each.
Tips
- Keep
winminheightandwinminwidthat a comfortable value (5–10) so non-focused windows remain readable - Use
<C-w>=to temporarily equalize all windows when you need side-by-side comparison - This pairs well with
set splitright splitbelowfor a consistent split direction - Start conservatively (
winwidth=80,winheight=10) and increase until the automatic resizing feels natural