From 625a72d89db24e9b44cecf3e1132bc8078730ee1 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Tue, 31 Jan 2023 17:56:50 +0000 Subject: Add resize-mode to make resizing panes faster and better --- plugin/resize-mode.vim | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 plugin/resize-mode.vim (limited to 'plugin') 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 +, -, <, > 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 + call enter_resize_mode('+') +noremap - call enter_resize_mode('-') +noremap > call enter_resize_mode('>') +noremap < call enter_resize_mode('<') -- cgit