Is there an easy way to move an adjacent tab in Vim to current window as a split?
While looking around I reached a mailing list discussion where someone said it\'s the r
I am providing two solutions, the first one I checked myself and I can guarantee it's working. The second, I am trying soon.
First solution: install this plugin http://www.vim.org/scripts/script.php?script_id=1961 by simply creating the folder ~/.vim/plugin
and downloading the file Tabmerge.vim
into the folder. Then, when you have two tabs and you type
:Tabmerge
you will merge the two tabs into one, splitted horizontally and top
aligned. Check out the link to find a complete usage guide.
Alternatively, check out this page http://vim.wikia.com/wiki/Move_current_window_between_tabs for the code of two functions to move current window between tabs. Here the functions (which I didn't try yet):
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
and
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