i’ve been a licensed user since 2013-01-17. sublime is the single most useful developer tool in my arsenal and i love it. thank you to everyone that has contributed.
the one thing that could make sublime better for me is if there were a way to collapse all windows into one. my working patterns involve keeping multiple project windows open all the time. i work in an area where i contribute to multiple projects simultaneously and context switch from one to another dozens of times a day. often while i am waiting for some longer running bottleneck to complete on one project, i will switch to something else whilst leaving sublime windows open that often contain unsaved work, code and notes. sublime’s ability to recover from a system crash without losing the content of my open windows has hardwired these behaviours into my daily routines for nearly a decade.
the problem is that i often have upwards of a dozen sublime windows open permanently and finding the one i want to work on is cumbersome. if i could hit a magic key combination and collapse all my sublime windows into one, with an easy way to scroll through a list of open projects in order to find the one i need, i would be the sublimest of happy developer bunnies in the world.
please, pretty please can you add this feature for me and all the other context switchers out there.
thank you!
One sublime window to rule them all
At least on MacOS multiple windows can be grouped into one via native tabs.
ST is set to use OS defaults but can ask OS to always do it via "native_tabs": "preferred",
yes. as a fedora user, i’m a little jealous of that one thing you mac people get that we don’t.
An alternative would be to use a quick panel to switch windows via fuzzy search quickly.
Theoretically GotoWindow package is doing that, but its implementation looks rather hacky and dated. Don’t expect it to work anymore as it uses OS APIs to switch windows.
A “Goto: Window” command can however be implemented with native API functions for Sublime Text 4.
Here’s a first shot.
Packages/User/Default.sublime-commands
[
{ "caption": "Goto: Window", "command": "goto_window"},
]
Packages/User/Default.sublime-keymap
[
{ "keys": ["ctrl+k", "ctrl+tab"], "command": "show_overlay", "args": {"overlay": "command_palette", "command": "goto_window"} },
]
Packages/User/goto_window.py
import os
import sublime
import sublime_plugin
class WindowInputHandler(sublime_plugin.ListInputHandler):
def name(self):
return "window_id"
def placeholder(self):
return "Chosse a window"
def list_items(self):
items = []
kind_project = [sublime.KIND_ID_NAMESPACE, "🗔", "Project"]
kind_file = [sublime.KIND_ID_NAVIGATION, "🗔", "File"]
for window in sublime.windows():
active_file_name = "untitled"
view = window.active_view()
if view:
file_name = view.file_name()
if file_name:
active_file_name = os.path.basename(file_name)
elif view.name():
active_file_name = view.name()
project_file_name = window.project_file_name()
if project_file_name:
title = f"Project: {os.path.splitext(os.path.basename(project_file_name))[0]}"
kind = kind_project
details = [
f"Active File: {active_file_name}"
]
else:
title = f"File: {active_file_name}"
kind = kind_file
details = [
f"Project: none"
]
items.append(
sublime.ListInputItem(
text=title,
value=window.id(),
annotation=f"Window {window.id()}",
kind=kind,
details=details
)
)
return items
class GotoWindowCommand(sublime_plugin.ApplicationCommand):
def input_description(self):
return "Goto Window"
def input(self, args):
if args.get("window_id") is None:
return WindowInputHandler()
return None
def run(self, window_id=None):
for window in sublime.windows():
if window.id() == window_id:
window.bring_to_front()
break
Can’t you just use projects and swap between them? This keeps separate workspaces so they open up just as you left them - including open or edited files.
I’m using tint2
on my Ubuntu with Gnome3 on Xorg though there should be something similar for Wayland too. It’s basically a strip at the bottom of the screen similar to the one found in Windows XP, yes I know, plus the fact that you can re-order the window position by dragging them. Then I am arranging my sublime windows to be delimited by other app windows that I use in that workspace:
I guess the point is just to be able to quickly switch between different open windows (maybe or maybe not representing a project each), rather than closing and opening workspaces - which “Quick Switch Project” or ProjectManager would already fulfill.
I sometimes have folders or single files open in a separate window without managing a project/workspace for them. There’s no way to switch to them quickly other than using OS functionality, which is not always the most efficient solution.
Thanks deathaxe.
I don’t work the same way as grenade but have found different projects useful for context switching within one workspace instance rather than bouncing between different Sublime versions. I can call each project something meaningful to help aid me even if I’ve not used the project for a while.
I found that the project files are easy to edit within sublime to then craft the one you want from something similar, meaning that you don’t need to make a new project from scratch each time.
Of course, each to his own - it was a question and suggestion.
Cheers, Cornishman