350

:vsplit (short form: :vs) split the Vim viewport vertically. :30vs splits the viewport, making the new window 30 characters wide. Once this 30 char window is created, how would one change it's size to 31 or 29?

With horizontal windows Ctrl-W + increases the number of lines by one. What is the equivalent command to increase the columns by one?

saluce
  • 13,035
  • 3
  • 50
  • 67
molicule
  • 5,481
  • 3
  • 29
  • 40
  • 16
    You can also do Ctrl-W 5+ to increase window height by 5 (or any number). Same goes for Ctrl-W 5- – AlexMA Feb 28 '13 at 19:27
  • 2
    `:h ^w` to see list of window commands. `:h ^ww` to see help of normal command `Ctrl-w w`. – qeatzy Jul 03 '17 at 05:23

10 Answers10

498

CTRL-W >

and

CTRL-W <

to make the window wider or narrower.

Keith Pinson
  • 7,835
  • 7
  • 61
  • 104
Herbert Sitz
  • 21,858
  • 9
  • 50
  • 54
275

And Ctr-W =

will make them equal

shime
  • 8,746
  • 1
  • 30
  • 51
RusAlex
  • 8,245
  • 6
  • 36
  • 44
116

In case you need HORIZONTAL SPLIT resize as well:
The command is the same for all splits, just the parameter changes:

- + instead of < >

Examples:
Decrease horizontal size by 10 columns

:10winc -

Increase horizontal size by 30 columns

:30winc +

or within normal mode:

Horizontal splits

10 CTRL+w -

30 CTRL+w +

Vertical splits

10 CTRL+w < (decrease)

30 CTRL+w > (increase)

freeo
  • 3,509
  • 1
  • 22
  • 17
  • 4
    +1. Just a minor comment: according to `:he winc` `ctrl+w [count] {arg}` works as well... – TrueY May 28 '14 at 09:11
  • What is the `10winc +/-` equivalent for vertical? I have `vertical resize 30`, but the shorter commands are preferred imo – mochsner Nov 03 '20 at 16:07
52

Another tip from my side:

In order to set the window's width to let's say exactly 80 columns, use

80 CTRL+W |

In order to set it to maximum width, just omit the preceding number:

CTRL+W |
artfulrobot
  • 20,637
  • 11
  • 55
  • 81
Phil
  • 3,282
  • 1
  • 20
  • 16
  • 7
    HEIGHT: This parameters' counterpart is "_" (shift+-) for adjusting the height. It's actually very easy to remember visually, since | is literally the vertical split and _ is literally the horizontal split line. Example: 15 CTRL+W _ Sets the current splits height to 15 rows. Another way to remember: you need SHIFT for absolute sizes, since both | and _ require shift to be pressed – freeo Dec 19 '14 at 01:05
34

I have these mapped in my .gvimrc to let me hit command-[arrow] to move the height and width of my current window around:

" resize current buffer by +/- 5 
nnoremap <D-left> :vertical resize -5<cr>
nnoremap <D-down> :resize +5<cr>
nnoremap <D-up> :resize -5<cr>
nnoremap <D-right> :vertical resize +5<cr>

For MacVim, you have to put them in your .gvimrc (and not your .vimrc) as they'll otherwise get overwritten by the system .gvimrc

Ted Naleid
  • 26,511
  • 10
  • 70
  • 81
14

Along the same lines, I use the following in my .vimrc to let me move through the splits, automatically expanding the one I'm moving to to its full size and shrinking all the rest to their minimum height or width:

" Switch between window splits using big J or K and expand the split to its 
" full size. 
" 
" Move vertically in the window through the horizontal splits... 
map <C-J> <C-w>j<C-w>_ 
map <C-K> <C-w>k<C-w>_ 

" Move horizontally in the window through the vertical splits... 
map <C-H> <C-w>h<C-w>\| 
map <C-L> <C-w>l<C-w>\| 
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
8

This is what I am using as of now:

nnoremap <silent> <Leader>= :exe "resize " . (winheight(0) * 3/2)<CR>
nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>
nnoremap <silent> <Leader>0 :exe "vertical resize " . (winwidth(0) * 3/2)<CR>
nnoremap <silent> <Leader>9 :exe "vertical resize " . (winwidth(0) * 2/3)<CR>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
meain
  • 833
  • 9
  • 28
8

For changing width use "vertical resize" and for changing height use "resize".

I have done following mapping in my .vimrc

  1. ALT will increase width of the selected split

  2. ALT will decrease width of the selected split

  3. ALT will increase height of the selected split

  4. ALT will decrease height of the selected split

My .vimrc code:

nmap <M-Right> :vertical resize +1<CR>
nmap <M-Left> :vertical resize -1<CR>
nmap <M-Down> :resize +1<CR>
nmap <M-Up> :resize -1<CR>

Vim Resize Splits more quickly

ABN
  • 1,024
  • 13
  • 26
6

I am using numbers to resize by mapping the following in .vimrc

nmap 7 :res +2<CR> " increase pane by 2 
nmap 8 :res -2<CR> " decrease pane by 2
nmap 9 :vertical res +2<CR> " vertical increase pane by 2
nmap 0 :vertical res -2<CR> " vertical decrease pane by 2
Gajendra Jena
  • 490
  • 6
  • 7
3

I am using the below commands for this:

set lines=50     " For increasing the height to 50 lines (vertical)
set columns=200  " For increasing the width to 200 columns (horizontal)
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
imbichie
  • 1,510
  • 3
  • 13
  • 23