Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a command in Vim/gVim to combine two or more tabs into a single split window?

Tags:

vim

split

tabbed

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

like image 532
Jason Down Avatar asked Jan 06 '11 14:01

Jason Down


People also ask

How do I open multiple tabs in Gvim?

It can be anything. To open more tabs in this instance, you can run the command: $ gvim --servername GVIM --remote-tab file1 file2 file3 ... Save this answer.

How do I make multiple windows in Vim?

To open a new VIM window next to the existing one, press <Ctrl>+<w> then press <v>. You can move to the left window again by pressing <Crtl>+<w> and then pressing <h>. To open a new VIM window on the bottom of the currently selected window, press <Ctrl>+<w> then press <s>.


3 Answers

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)...

like image 147
Zsolt Botykai Avatar answered Oct 22 '22 15:10

Zsolt Botykai


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.

like image 22
Herbert Sitz Avatar answered Oct 22 '22 16:10

Herbert Sitz


Try this script:

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

like image 1
Luke H Avatar answered Oct 22 '22 15:10

Luke H