Vim Tips Wiki
Advertisement

Previous TipNext Tip

Tip: #427 - Fast window resizing with plus/minus keys

Created: February 14, 2003 6:00 Complexity: basic Author: Bob Heckel Version: 5.7 Karma: 141/59 Imported from: Tip#427

Depending on your willingness to occasionally consume the + and - keys, here's a fast way to resize the active window if you have more than one window open:


if bufwinnr(1)

map + <C-W>+ 
map - <C-W>- 

endif


I normally use the scrollpad + and - keys.


The map eliminates the need for time-consuming chording and if you liked chording, you'd be using Emacs instead of Vim anyway...

Comments

Depending on your screen size, and your brain's memory capacity for more vim mappings (caution this will affect your every day speech when vim mappings exceeds 100), you may want to increase the windows' frame size to some preselected settings. I am sure there is a more elegant solution for incrementing the size of this (get the current setting into the buffer, increment it and set it again). I am too lazy so I use full screen and min screen based on my 1400x1050 and guifont=lucida_console:h7:w5 " small (94 lines in one screen)


map <M-[> :set co=210<CR>:set lines=180<CR> "fullscreen map <M-]> :set co=50<CR>:set lines=50<CR> "minimumscreen map <M-\> :set co=120<CR>:set lines=80<CR> "my default screen size


gmann--AT--femto.med.unc.edu , February 16, 2003 15:18


I'm not much for resizing windows.. However, I stole your tip and made a slight modification:

if bufwinnr(1)

map - <C-W><UP> 
map + <C-W><DOWN> 

endif

Now I can go through my open windows very easily with + and - :)

webmaster--AT--topfx.com , February 19, 2003 20:32


the <C-W><UP> and <C-W><DOWN> work well if you're only split horizontally, but if you split vertically, this might make rotating between windows a bit easier:

if bufwinnr(1)

map - <C-W><C-W> 
map + <S-C-W><S-C-W> 

endif

HTH

alex--AT--netWindows.org , February 24, 2003 14:17


I have several mappings for window movement/operations in my .vimrc, too. Here are some of them:

| map + <c-w>+ | map - <c-w>- What was posted as the original tipp. I had the same idea, i think ;-)

| map <c-n> <c-w>< | map <c-m> <c-w>> Similar to the mappings above, but for horizontal resizing.

| map <c-w>F <c-w>_<c-w><bar> Fullscreen the actual window. (not depending on the terminal's size)

| map <Up> <c-w>k<c-w>_<c-w><bar> | map <Down> <c-w>j<c-w>_<c-w><bar> | map <Left> <c-w>h<c-w>_<c-w><bar> | map <Right> <c-w>l<c-w>_<c-w><bar> Walking through windows and make them fullscreen at the same time.

In addition, I've set winminwidth and winminheight to 0.

cu, Daniel


daniel--AT--brot.t0c.de , February 26, 2003 22:20


Using the ideas above I come up with this version :)

"Fast window resizing with +/- keys (horizontal); / and * keys (vertical) if bufwinnr(1)

map <kPlus> <C-W>+ 
map <kMinus> <C-W>- 
map <kDivide> <c-w>< 
map <kMultiply> <c-w>> 

endif

+ / - didn't work for me, it moved the cursor up and down, but with kPlus, etc. it's OK.

Laszlo

szathml--AT--delfin.klte.hu , June 28, 2003 18:26


I have added the following to my vimrc file. This came from the list, author unknown. Holding down the SHIFT key and using the arrow keys is quick and efficient for resizing the windows.

" Window resizing mappings /**/


fishburn--AT--ianywhere.com , November 11, 2003 13:53


This is what I use.

" Maps Alt-[h,j,k,l] to resizing a window split map <silent> <A-h> <C-w>< map <silent> <A-j> <C-W>- map <silent> <A-k> <C-W>+ map <silent> <A-l> <C-w>>

" Maps Alt-[s.v] to horizontal and vertical split respectively map <silent> <A-s> :split<CR> map <silent> <A-v> :vsplit<CR>

" Maps Alt-[n,p] for moving next and previous window respectively map <silent> <A-n> <C-w><C-w> map <silent> <A-p> <C-w><S-w>

I find it very useful as my shift and ctrl key are overused for mapping and I don't like moving my hand to the arrow keys (yes I am very very lazy)

vramesh2--AT--uiuc.edu , January 27, 2007 22:31


Advertisement