diff options
-rw-r--r-- | plugin/resize-mode.vim | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/plugin/resize-mode.vim b/plugin/resize-mode.vim new file mode 100644 index 0000000..a28e26c --- /dev/null +++ b/plugin/resize-mode.vim @@ -0,0 +1,29 @@ +" Using <C-w>+, <C-w>-, <C-w><, <C-w>> without a number will enter a "resize" +" mode where the pane can be resized by repeatedly pressing those keys. + +if !exists("g:vim_fieldmarshal_resize_skip") + let g:vim_fieldmarshal_resize_skip = 3 +endif + +function! s:enter_resize_mode(chr) abort + let c = a:chr + if v:count != 0 + exec "wincmd " . c + return + endif + + exec g:vim_fieldmarshal_resize_skip . "wincmd " . c + redraw + + let c = nr2char(getchar()) + while c == '<' || c == '>' || c == '+' || c == '-' + exec g:vim_fieldmarshal_resize_skip . "wincmd " . c + redraw + let c = nr2char(getchar()) + endwhile +endfunction + +noremap <C-w>+ <cmd>call <sid>enter_resize_mode('+')<cr> +noremap <C-w>- <cmd>call <sid>enter_resize_mode('-')<cr> +noremap <C-w>> <cmd>call <sid>enter_resize_mode('>')<cr> +noremap <C-w>< <cmd>call <sid>enter_resize_mode('<')<cr> |