Reputation: 1503
On my mac, I work with a lot of tabs and windows in SublimeText 3. I often like to pull tabs out to create a new window but later, I want to be able to easily consolidate them.
Scenario: I have two SublimeText windows open, each with 5 tabs. Now, I'd like to merge all the tabs of window 2 into window 1 so I only have one remaining window with 10 tabs.
Chrome has a fabulous extension called Merge Windows that demonstrates this behavior perfectly.
How would I do this in SublimeText 3?
Upvotes: 23
Views: 10531
Reputation: 934
[Not sure for other OS but for MAC it is easy and very useful]
In mac, open sublime,
click Window -> Click Merge all Windows
Also make sure that this won't work if you just have one window open which is pretty obvious.
Upvotes: 9
Reputation: 1503
I have created a sublime package to help solve this problem called Merge Windows.
It can be downloaded from github or through Sublime using Package Control
Upvotes: 19
Reputation: 406
This isn't exactly what you're asking for but I think this is close enough:
Drag the tab from the "source" window to the "target" Window and hover near the other tabs in the source window. Then drop it there. Voila. You've moved one tab. Rinse and repeat for the other tabs.
Upvotes: 6
Reputation: 4031
This is doable, but not supported and could potentially blow away your buffers if you mess up. So backup this file.
/Users/username/Library/Application Support/Sublime Text 3/Local/Session.sublime_session
This file contains all of your session data, all windows, tabs search history, etc.
You can move an entire window of tabs from one window to another with the following instructions:
Look for the "Windows" JSON entry, inside of that is a list of windows, the list is indicated with the [] brackets and is comma separated. Inside of each 'Window' entry in the 'Windows' list is a "Buffers" list, each 'Buffer' represents a Tab. There is also a "groups" list that contains a "sheets" list which functions identically but contains information about the tabs and not so much the content.
There are other bits of data in there that we are not interested in for this exercise, but it is very important that the file passes JSON validation before you open Sublime.
"windows":
[
{
"auto_complete":
{
"selected_items":
[
]
},
"buffers":
[
{
"contents": "This tab has not been saved and is in Window 1",
"settings":
{
"buffer_size": 46,
"line_ending": "Unix",
"name": "This tab has not been saved and is in Window 1"
}
},
{
"file": "/Users/username/Desktop/This file has been saved and not changed and is in Window 1",
"settings":
{
"buffer_size": 59,
"line_ending": "Unix",
"name": "This file has been saved and not changed and is in Window 1"
}
}
],
"groups":
[
{
"selected": 0,
"sheets":
[
{
"buffer": 0,
"semi_transient": false,
"settings":
{
"buffer_size": 46,
"regions":
{
},
"selection":
[
[
46,
46
]
],
"settings":
{
"auto_name": "This tab has not been saved and is in Window 1",
"syntax": "Packages/Text/Plain text.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 0,
"type": "text"
},
{
"buffer": 1,
"file": "/Users/username/Desktop/This file has been saved and not changed and is in Window 1",
"semi_transient": false,
"settings":
{
"buffer_size": 59,
"regions":
{
},
"selection":
[
[
59,
59
]
],
"settings":
{
"auto_name": "This file has been saved and not changed and is in",
"syntax": "Packages/Text/Plain text.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 1,
"type": "text"
}
]
}
]
},
{
"buffers":
[
{
"contents": "This tab is also unsaved and in Window 2.",
"settings":
{
"buffer_size": 41,
"line_ending": "Unix",
"name": "This tab is also unsaved and in Window 2."
}
}
],
"groups":
[
{
"selected": 0,
"sheets":
[
{
"buffer": 0,
"semi_transient": false,
"settings":
{
"buffer_size": 41,
"regions":
{
},
"selection":
[
[
41,
41
]
],
"settings":
{
"auto_name": "This tab is also unsaved and in Window 2.",
"syntax": "Packages/Text/Plain text.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 0,
"type": "text"
}
]
}
]
}
If you relocate each 'buffer' entry from the second 'window' to the end of the first, and repeat for each 'sheet' under 'groups'. Then update the 'buffer' number to be higher for each of the sheet entries, they should be sequential following the entry that was previously there. When you open Sublime 3 you will notice all your tabs from Window 2 are now in Window 1.
The edited session file will look kinda like this:
"windows":
[
{
"auto_complete":
{
"selected_items":
[
]
},
"buffers":
[
{
"contents": "This tab has not been saved and is in Window 1",
"settings":
{
"buffer_size": 46,
"line_ending": "Unix",
"name": "This tab has not been saved and is in Window 1"
}
},
{
"file": "/Users/username/Desktop/This file has been saved and not changed and is in",
"settings":
{
"buffer_size": 59,
"line_ending": "Unix",
"name": "This file has been saved and not changed and is in"
},
},
{
"contents": "This tab is also unsaved and in Window 2.",
"settings":
{
"buffer_size": 41,
"line_ending": "Unix",
"name": "This tab is also unsaved and in Window 2."
}
}
],
"groups":
[
{
"selected": 0,
"sheets":
[
{
"buffer": 0,
"semi_transient": false,
"settings":
{
"buffer_size": 46,
"regions":
{
},
"selection":
[
[
46,
46
]
],
"settings":
{
"auto_name": "This tab has not been saved and is in Window 1",
"syntax": "Packages/Text/Plain text.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 0,
"type": "text"
},
{
"buffer": 1,
"file": "/Users/username/Desktop/This file has been saved and not changed and is in",
"semi_transient": false,
"settings":
{
"buffer_size": 59,
"regions":
{
},
"selection":
[
[
59,
59
]
],
"settings":
{
"auto_name": "This file has been saved and not changed and is in",
"syntax": "Packages/Text/Plain text.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 1,
"type": "text"
},
{
"buffer": 2,
"semi_transient": false,
"settings":
{
"buffer_size": 41,
"regions":
{
},
"selection":
[
[
41,
41
]
],
"settings":
{
"auto_name": "This tab is also unsaved and in Window 2.",
"syntax": "Packages/Text/Plain text.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 0,
"type": "text"
}
]
}
]
},
{
"buffers":
[
],
"groups":
[
{
"selected": 0,
"sheets":
[
]
}
]
}
There you have it. It's not pretty or direct, but it will get the job done and could be scripted using Python, Perl, or a number of other languages pretty quickly especially if you used a JSON library.
Upvotes: 1