How do I temporarily zoom a split window to full screen and then restore the layout?
Answer
<C-w>| and <C-w>_ / <C-w>=
Explanation
Vim lets you temporarily maximize a split window to full width or full height, and then restore all windows to equal sizes with <C-w>=. This gives you a quick zoom-in/zoom-out workflow without closing any splits or rearranging your layout.
How it works
<C-w>_maximizes the current window's height (it takes up all available vertical space)<C-w>|maximizes the current window's width (it takes up all available horizontal space)- Using both together (
<C-w>_ <C-w>|or<C-w>|<C-w>_) effectively "zooms" the window to fill the entire screen <C-w>=equalizes all window sizes, restoring the balanced layout
The other splits are not closed — they shrink to a single line or column and remain accessible.
Example
You have three vertical splits open:
┌──────┬──────┬──────┐
│ │ │ │
│ a.js │ b.js │ c.js │
│ │ │ │
└──────┴──────┴──────┘
With the cursor in b.js, press <C-w>| to zoom it horizontally:
┌┬────────────────┬┐
││ ││
││ b.js ││
││ ││
└┴────────────────┴┘
The other windows collapse to a single column each. Press <C-w>= to restore:
┌──────┬──────┬──────┐
│ │ │ │
│ a.js │ b.js │ c.js │
│ │ │ │
└──────┴──────┴──────┘
Tips
- Map a toggle zoom for convenience in your vimrc:
nnoremap <leader>z <C-w>_<C-w>\|
nnoremap <leader>Z <C-w>=
- Use a count with these commands:
10<C-w>_sets the window height to exactly 10 lines,80<C-w>|sets the width to 80 columns <C-w>o(or:only) closes all other windows entirely — use this only when you truly want to dismiss the other splits, not just hide them temporarily<C-w>Tmoves the current window to a new tab if you want a full-screen view that coexists with your split layout in another tab- The collapsed windows still show their status lines, so you can see which files are in each position
- Combine with
<C-w>wor<C-w>h/j/k/lto navigate to the collapsed windows when needed — they expand as soon as you start editing in them (ifequalalwaysis set)