vim-smartsplit

You're lazy. Let Vim decide your split directions.
git clone git://git.danielmoch.com/vim-smartsplit.git
Log | Files | Refs | README

commit f937f35271cc43918cf481aa9a493b33c5d50719
parent 9a938797f92572b862c90107657fedd68cf10e08
Author: Denys Pavlov <denys.pavlov@gmail.com>
Date:   Mon,  2 Sep 2019 18:46:32 +0800

Add a CmdSplit command as a :vertical counterpart

Pre-pending a command that creates splits with `:vertical` makes it
create vertical instead of horizontal splits. Adding a `:CmdSplit`
command enables the splits to be smart instead. This lets tools like
tpope/vim-fugitive's `Gstatus` respect your screen real-estate.

Diffstat:
Mdoc/smartsplit.vim | 5+++++
Mplugin/smartsplit.vim | 9+++++++++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/doc/smartsplit.vim b/doc/smartsplit.vim @@ -55,6 +55,11 @@ Help A smart version of |:help|. Horizontal versus vertical splitting is determined as described in |:Split|. + *smartsplit-CmdSplit* *:CmdSplit* +CmdSplit {cmd} A smart version of |:vertical|. Horizontal versus + vertical splitting is determined as described in + |:Split|. + ============================================================================= 2. ABOUT *smartsplit-about* diff --git a/plugin/smartsplit.vim b/plugin/smartsplit.vim @@ -66,6 +66,14 @@ function! s:Buffer(...) endif endfunction +function! s:CmdSplit(command) + if s:WinWidth() + execute 'vertical '.a:command + else + execute a:command + endif +endfunction + augroup smartsplit autocmd! autocmd VimResized * call <sid>DiffOpt() @@ -75,6 +83,7 @@ augroup END command! -complete=file -nargs=? New call <sid>NewWindow(<f-args>) command! -complete=help -nargs=1 Help call <sid>Help(<f-args>) command! -complete=buffer -nargs=1 Buffer call <sid>Buffer(<f-args>) +command! -complete=command -nargs=1 CmdSplit call <sid>CmdSplit(<f-args>) command! Split call <sid>Buffer() let &cpo = s:save_cpo