Wikia

Vim Tips Wiki

Resize splits more quickly

Talk0
1,610pages on
this wiki
Revision as of 21:18, March 18, 2012 by 79.184.64.61 (Talk)

Tip 1215 Printable Monobook Previous Next

created April 26, 2006 · complexity basic · author Robert · version 6.0


You know that you can use "<c-w> +" and "<c-w> -" to resize a split window, but did you know you can repeat the resize commands (e.g. "10<c-w>+" will increase the window size by 10).

While this is a basic tip, I sometimes need to split windows in terminals and ended up killing my fingers while resizing them until I realized that the command could be repeated.

Other resizing tips are at VimTip427.

Comments

Here are some other suggestions. Increasing a window size by a factor of 1.5 and decreasing by a factor of 0.67 seems to work well for me.

nnoremap <silent><Leader>= :<C-u>exe "norm! z".(line("$")<=winheight(0)?line("$")+&so:(winheight(0)+&so+1)*3/2)."\<lt>CR>"<CR>
nnoremap <silent><Leader>- :<C-u>exe "norm! z".(winheight(0)*2/3)."\<lt>CR>"<CR>
nnoremap <Leader>_ <C-w>_
nnoremap <Leader><Bar> <C-w><Bar>

You can also use the :resize command for this, e.g:

:res +10
:res -10
:res 20

WinWalker has resizing as well as a lot of other stuff. I just uploaded another version. It's only for Vim 7, though.


I have reduced these mappings to (in my opinion the most compact form):

nnoremap <silent> + :exe "resize " . (winheight(0) * 3/2)<CR>
nnoremap <silent> - :exe "resize " . (winheight(0) * 2/3)<CR>

You can also drag the split with the mouse to where you want it. Just grab ahold of the statusline that makes the split, and drag. I know this works at under Windows, both in GUI and in non-GUI.

It also works under Unix. I also like to use the "<c-w> =" to make all windows same size (once I've resized 10 subwindows and got lost on the original one I'm working on). "<c-w> _" (underscore) is very powerfull too, to maximize one subwindow


I have happily created submodes for various window commands with this plugin http://www.vim.org/scripts/script.php?script_id=2467 It has some drawbacks that the submode name length is limited, you can't use spaces, but it makes resizing easier.

Advertisement | Your ad here

Around Wikia's network

Random Wiki