I want to do window resizing in vim similarly to how I do it in tmux.
With my tmux bindings (of the form bind -r J resize-pane -D 5, where the -r is for repeat) I can do <C-b>JJJ, which is the same number of keys and effect as vim's 15<C-w>+, but much less thinking because I can just move the split until it looks right, rather than deciding a number of rows/cols in advance.
Another example: I want to be able to press <C-w>++++--, and have it perform the same action as pressing <C-w>+<C-w>+<C-w>+<C-w>+<C-w>-<C-w>-. (Although I'd probably want to remap it again to do 5 lines/cols per move instead of 1).
Is this kind of repeat/timeout mode possible in vim bindings?
That's a tricky one, but I'll share my method of handling this, as I think it's even easier than the <C-w> methods (which I used for a long time, and found bothersome):
" simplify resizing splits
if has('unix')
nnoremap ^[j <C-w>-
nnoremap ^[k <C-w>+
nnoremap ^[h <C-w><
nnoremap ^[l <C-w>>
else
nnoremap <M-j> <C-w>-
nnoremap <M-k> <C-w>+
nnoremap <M-h> <C-w><
nnoremap <M-l> <C-w>>
endif
The ^[ characters must be replaced by an actual escape. Create it in insert mode by pressing Ctrl+v, then escape. This was required to use meta+x in bash on Linux. Now in both OSes I can just hold Alt and the hjkl keys to resize splits, including holding down, say, Alt+h to horizontally shrink the split I'm in. They also work with counts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With