Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert split windows to tabs and vice versa in Vim

Tags:

vim

split

For example, I use 3 split windows to open 3 different files:

    +---------------+-----------+                          
    |               |           |                          
    |   window 1    |           |                          
    |               |           |                          
    +---------------+           |                          
    |               | window 3  |                          
    |               |           |                          
    |   window 2    |           |                          
    |               |           |                          
    |               |           |
    +---------------+-----------+

Now, I want to open them with 3 different tabs and vice versa

Is there any trick to achieve this? Or do I need any plugin?

Besides, if I want to display 3 buffers in 3 full screen windows (as opposed to a split window), what should I do?

like image 592
simon_xia Avatar asked Feb 04 '15 05:02

simon_xia


2 Answers

Not sure if there is a plugin, which will do all splits at once. But there is a way to do it one at a time

For moving the current split into a new tab use ctrl + w, T (shift + t)

repeat the above process for all splits.

Now for getting the tab in to split, you can make use of a plugin call "Tabmerge", download Tabmerge.vim from http://www.vim.org/scripts/script.php?script_id=1961 to ~/.vim/plugin

then to merge the tab use :Tabmerge [tab number] [top|bottom|left|right]

like image 108
Naks Avatar answered Sep 29 '22 11:09

Naks


If you are careful with your buffer list, you can use :sball and :tab sball to open in windows or tabs, respectively.

like image 30
Ben Avatar answered Sep 29 '22 13:09

Ben