Reputation: 3331
I'm trying to remap the regular vim shortcut Ctrl-W+< and Ctrl-W+> to resize the current active pane to the specified direction ('<' for left and '>' for right) but unfortunately I couldn't find a command which does that, only a command which increases/decreases the pane size by the specified amount, which is not what I need.
this is currently what I have:
nnoremap <C-w>> :vertical res +5<CR>
nnoremap <C-w>< :vertical res -5<CR>
But this increases the current window size by 5 columns no matter if I'm in the right pane or the left pane, which is not very intuitive.
Is there a command which resizes current window to left or right (similiar to Tmux way of doing those things)?
Upvotes: 4
Views: 1299
Reputation: 31070
You could set it based on the window number:
au! WinEnter * call SetWinAdjust()
fun! SetWinAdjust()
if winnr() > 1
nnoremap <C-w>> <C-w><
nnoremap <C-w>< <C-w>>
else
nnoremap <C-w>> <C-w>>
nnoremap <C-w>< <C-w><
endif
endfun
Upvotes: 1