How do I temporarily maximize a split window to full height or width?
Answer
<C-w>_ and <C-w>|
Explanation
When working with multiple splits, you sometimes need to focus on one window temporarily without closing the others. <C-w>_ maximizes the current window's height (in horizontal splits), and <C-w>| maximizes its width (in vertical splits). The other windows shrink to a single line or column but remain open, so you can restore them with <C-w>=.
How it works
<C-w>_— sets the current window height to the maximum available, shrinking all other horizontal splits to one line each<C-w>|— sets the current window width to the maximum available, shrinking all other vertical splits to one column each<C-w>=— equalizes all window sizes again when you are done focusing- Both commands accept a count:
10<C-w>_sets the window height to exactly 10 lines
Example
You have three horizontal splits open and need to focus on the middle one:
" Move to the middle window
<C-w>j
" Maximize its height
<C-w>_
" The other two windows collapse to single status lines
" When done, restore equal sizes:
<C-w>=
Tips
- Combine both for a "zoom" effect:
<C-w>_<C-w>|maximizes the current window in both dimensions - Use a count prefix with these commands to set an exact size rather than maximizing:
30<C-w>_sets height to 30 lines - Pair with
<C-w>=to quickly toggle between focused and balanced layouts - For a more permanent zoom, consider
:tab splitto open the current buffer in a new tab, then:tabclosewhen done