tab functions

This commit is contained in:
Haak Saxberg 2014-03-21 11:47:42 -07:00
parent 9b42ef227b
commit 1c318712eb

View file

@ -75,7 +75,7 @@ set rtp+=~/dotfiles/misc-files/powerline/powerline/bindings/vim
"
""" Easymotion
map / <Plug>(easymotion-sn)
map / <Plug>(easymotion-tn)
omap / <Plug>(easymotion-tn)
map n <Plug>(easymotion-next)
map N <Plug>(easymotion-prev)
let g:EasyMotion_landing_highlight = 1
@ -253,3 +253,51 @@ function! s:RunShellCommand(cmdline)
setlocal nomodifiable
1
endfunction
function! MoveToPrevTab()
"there is only one window
if tabpagenr('$') == 1 && winnr('$') == 1
return
endif
"preparing new window
let l:tab_nr = tabpagenr('$')
let l:cur_buf = bufnr('%')
if tabpagenr() != 1
close!
if l:tab_nr == tabpagenr('$')
tabprev
endif
sp
else
close!
exe "0tabnew"
endif
"opening current buffer in new window
exe "b".l:cur_buf
endfunc
function! MoveToNextTab()
"there is only one window
if tabpagenr('$') == 1 && winnr('$') == 1
return
endif
"preparing new window
let l:tab_nr = tabpagenr('$')
let l:cur_buf = bufnr('%')
if tabpagenr() < tab_nr
close!
if l:tab_nr == tabpagenr('$')
tabnext
endif
sp
else
close!
tabnew
endif
"opening current buffer in new window
exe "b".l:cur_buf
endfunc
nnoremap <C-m> :call MoveToNextTab()<CR><C-w>H
nnoremap <C-n> :call MoveToPrevTab()<CR><C-w>H