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

How do I resize split windows in Vim?

Answer

<C-w>+

Explanation

When working with multiple split windows, you often need to resize them to see more content in one pane. Vim provides keyboard shortcuts to increase or decrease the height and width of the current window without touching the mouse.

How it works

All resize commands start with <C-w> (Ctrl+W):

  • <C-w>+ — Increase current window height by 1 line
  • <C-w>- — Decrease current window height by 1 line
  • <C-w>> — Increase current window width by 1 column
  • <C-w>< — Decrease current window width by 1 column
  • <C-w>= — Make all windows equal size
  • <C-w>_ — Maximize current window height
  • <C-w>| — Maximize current window width

Prefix any of these with a count to resize by more: 5<C-w>+ increases height by 5 lines.

Example

You have a horizontal split with a small terminal-like buffer on the bottom:

+------------------+
|  main.go (large) |
|                  |
+------------------+
|  test output (2) |
+------------------+

Move to the bottom window and press 10<C-w>+ to give it 10 more lines:

+------------------+
|  main.go         |
+------------------+
|  test output     |
|  (12 lines now)  |
+------------------+

Tips

  • Use :resize N or :vertical resize N to set an exact size in lines/columns.
  • Use :resize +N and :resize -N for relative adjustments via Ex command.
  • <C-w>= is great for quickly restoring a balanced layout after manually resizing.
  • In Neovim, you can also use <C-w> followed by arrow keys to resize interactively.

Next

How do you yank a single word into a named register?