vim/autoload/window.vim
function! window#move(key) abort
let t:curwin = winnr()
exec 'wincmd ' . a:key
if (t:curwin == winnr())
" We haven't moved, so we create a new window.
if (match(a:key, '[jk]'))
wincmd v
else
wincmd s
endif
" Jump to the newly created window.
exec 'wincmd ' . a:key
endif
endfunction