Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- nnoremap <c-w><c-j> :call <sid>smart_split('j')<cr>
- nnoremap <c-w><c-k> :call <sid>smart_split('k')<cr>
- nnoremap <c-w><c-h> :call <sid>smart_split('h')<cr>
- nnoremap <c-w><c-l> :call <sid>smart_split('l')<cr>
- function! s:smart_split(cmd)
- " original window number
- let wn = winnr()
- " try to move to other window
- exec 'wincmd ' . a:cmd
- " do nothing if window changed
- if wn != winnr() | return | endif
- " otherwise split vertical or horizontal based on a:cmd
- exec 'wincmd ' . (a:cmd =~# '[lh]' ? 'v' : 's')
- " move to new window. You only need this 50% of time.
- exec 'wincmd ' . a:cmd
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement