6 years ago
Sometimes it's awkward to resize a window because the default commands (Ctrl-w + {x}) are very difficult to type repeatedly. It's true that one can always use a numeric argument (or just resize the window with the mouse) but it is hard to calculate visually how many repetitions you need. This snippet lets you repeat the resize command omitting the Ctrl-w part in other than the first time while only resize commands are used.
nnoremap <C-W>- :call RepeatResize('-')<CR> nnoremap <C-W>+ :call RepeatResize('+')<CR> nnoremap <C-W>< :call RepeatResize('<')<CR> nnoremap <C-W>> :call RepeatResize('>')<CR> function! RepeatResize(first) let l:command = a:first while stridx('+-><', l:command) != -1 execute "normal! \<C-w>" . l:command redraw let l:command = nr2char(getchar()) endwhile endfunction