Vim Tips Wiki
Advertisement

This two functions allows to move window between tabs:

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

My mapping for them:

	map <A-.> :call MoveToNextTab()<CR>
	map <A-,> :call MoveToPrevTab()<CR>

Comments

This looks like it might be promising, but you should explain better what it does, and how it's different from/why it can't use :help :tabmove or :help CTRL-W_T. --Fritzophrenic 16:06, 18 April 2008 (UTC)

Advertisement