vimtricks.wiki Concise Vim tricks, one at a time.

How do I make all split windows the same size?

Answer

<C-w>=

Explanation

The <C-w>= (Ctrl+w then =) command resizes all open split windows so they have equal width and height. This is incredibly useful after creating multiple splits or after resizing your terminal, when windows end up with uneven dimensions.

How it works

  • <C-w> is the window command prefix
  • = tells Vim to equalize the dimensions of all visible windows
  • Horizontal splits get equal height, vertical splits get equal width
  • The command affects all windows in the current tab page

Example

You have three horizontal splits open, but after resizing one with <C-w>+ and <C-w>-, they are uneven:

┌──────────────────┐
│ file1.txt (5 rows)│
├──────────────────┤
│ file2.txt (20row)│
├──────────────────┤
│ file3.txt (5 rows)│
└──────────────────┘

Pressing <C-w>= makes all three windows the same height:

┌──────────────────┐
│ file1.txt (10row)│
├──────────────────┤
│ file2.txt (10row)│
├──────────────────┤
│ file3.txt (10row)│
└──────────────────┘

Tips

  • Use <C-w>+ to increase the current window's height by one line, or 5<C-w>+ for five lines
  • Use <C-w>- to decrease the current window's height by one line
  • Use <C-w>> to increase width and <C-w>< to decrease width of the current window
  • Use <C-w>_ to maximize the current window's height
  • Use <C-w>| to maximize the current window's width
  • Use :resize 20 to set a window to exactly 20 lines tall
  • Use :vertical resize 80 to set a window to exactly 80 columns wide
  • If you want windows to automatically equalize when you open or close a split, no extra config is needed — Vim does this by default unless you have set noequalalways

Next

How do I edit multiple lines at once using multiple cursors in Vim?