351

: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?

2
  • 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, 2013 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 3, 2017 at 5:23

10 Answers 10

499

CTRL-W >

and

CTRL-W <

to make the window wider or narrower.

6
  • 128
    or :30winc > and :30winc < to have 30 more/less characters wide.
    – Benoit
    Dec 6, 2010 at 16:41
  • 95
    or 30CTRL-W > to stay in the spirit of the answer.
    – Xavier T.
    Dec 6, 2010 at 16:51
  • 54
    :vertical resize 30 to resize the current window to exactly 30 characters wide. Dec 6, 2010 at 18:39
  • 6
    :res <N> to set the current window size to exactly N rows (for height not width) Apr 30, 2013 at 16:43
  • 2
    or CTRL-W = to make them equal
    – Hritik
    Feb 17, 2022 at 8:31
276

And Ctr-W =

will make them equal

3
  • 12
    :winc = This will also make them equal. Nov 13, 2013 at 5:29
  • 2
    That's for horizontal splits, right? What would be the equivalent for vertical splits? Aug 4, 2015 at 18:18
  • 3
    @JoséRamón This command works for both horizontal and vertical splits.
    – Nathan
    Sep 26, 2015 at 17:58
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)

2
  • 4
    +1. Just a minor comment: according to :he winc ctrl+w [count] {arg} works as well...
    – TrueY
    May 28, 2014 at 9:11
  • What is the 10winc +/- equivalent for vertical? I have vertical resize 30, but the shorter commands are preferred imo
    – mochsner
    Nov 3, 2020 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 |
1
  • 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, 2014 at 1: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

3
  • 1
    what does that <cr> mean in the end? Haven't saw that in nnoremap before
    – Zen
    Oct 11, 2014 at 3:04
  • 2
    it's short for "carriage return", basically it's the equivalent of the user hitting return
    – Ted Naleid
    Oct 11, 2014 at 7:15
  • 1
    and is <D-left> = CTRL-D and left arrow?
    – mropp
    Nov 18, 2021 at 20:24
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>\| 
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>
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

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
2
  • I think you mean nmap 9 :vertical res +2<CR> instead of -2 for vertical increase
    – Zach
    May 2, 2018 at 16:57
  • This is really a nice binding. Thank you! Nov 1, 2019 at 15:58
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)

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.