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

How do I incrementally grow or shrink a split window by a specific number of lines or columns?

Answer

:resize +N / :resize -N

Explanation

:resize adjusts the height of the current window by a relative or absolute amount. Using +N or -N grows or shrinks it incrementally — letting you fine-tune split sizes precisely without reaching for the mouse or recalculating total dimensions.

How it works

  • :resize +N — increase the current window height by N lines
  • :resize -N — decrease the current window height by N lines
  • :resize N (no sign) — set height to exactly N lines
  • :vertical resize +N — increase width by N columns (for vertical splits)
  • :vertical resize -N — decrease width by N columns
  • Keyboard shortcuts in Normal mode:
    • <C-w>+ — increase height by 1 line
    • <C-w>- — decrease height by 1 line
    • <C-w>> — increase width by 1 column
    • <C-w>< — decrease width by 1 column
    • {count}<C-w>+ — increase height by {count} lines

Example

You have a small preview split at the bottom and want to make it taller:

:resize +10

Or use the keyboard shortcut: 5<C-w>+ to add 5 lines at once.

For a vertical split that feels too narrow:

:vertical resize +20

Tips

  • :resize 0 shrinks the window to its minimum (just the status bar)
  • <C-w>= equalizes all windows back to equal sizes if your layout gets messy
  • Map resize shortcuts for faster access:
    nnoremap <silent> <Right> :vertical resize +2<CR>
    nnoremap <silent> <Left>  :vertical resize -2<CR>
    nnoremap <silent> <Up>    :resize +2<CR>
    nnoremap <silent> <Down>  :resize -2<CR>
    

Next

How do I run a search and replace only within a visually selected region?