22

Is it possible to take two files that are open in separate tabs in gVim and combine them into one tab with a split/vsplit window? I'd prefer if there was a way to specify which tabs to join, but even something that is the opposite of :tab ball would be good enough.

Thanks

Jason Down
  • 21,731
  • 12
  • 83
  • 117

4 Answers4

14

Lots of handwork but...

:tabnew
:buffers "note the numbers
:split
:bn " where n is the number of 
<CTRL-W><CTRL-W>
:bn " for the other file
:tabonly " not necessary, closes every other tab

Or you can create a function for it which asks for buffer numbers, then creates the tab, and closes every other tab (for the opened files)...

Zsolt Botykai
  • 50,406
  • 14
  • 85
  • 110
  • 3
    This is just what I needed: `:buffers` to see the numbers, saw that the buffer I wanted to pull was 12, then with my cursor in the target pane, `:b 12`. Then buffer 12 is open in both places so just close the other one. – Matthew Feb 23 '16 at 19:26
9

There are a couple of functions published on the “Move current window between tabs” page in Vim Tips Wiki that should do what you want, or be easily modifiable to get exactly what you want.

ib.
  • 27,830
  • 11
  • 80
  • 100
Herbert Sitz
  • 21,858
  • 9
  • 50
  • 54
  • I modified the script so I can split vertically or horizontally when pulling the buffer over (I prefer vertical splits most of the time, but figured why not have the option). Thanks again for the link! – Jason Down Jan 06 '11 at 19:48
1

This one worked for me: TabMerge

If you're working with Plug, just add the following to your ~/.vimrc:

Plug 'vim-scripts/Tabmerge'

Elior Malul
  • 683
  • 6
  • 8
1

Try this script:

TabMerge http://www.vim.org/scripts/script.php?script_id=1961

Luke H
  • 3,125
  • 27
  • 31