Reputation: 1874
I save several projects in a same folder by manual click Project -> Save Project As...
and I used to use cmd + ctrl + p
to open Switch Project
list to switch between projects
and everything's works fine.
but today, I accidentally remove my Switch Project
list in by click Project -> Open Recent -> Clear Items
, so my Switch Project
list is empty now...
I know I could add them back through reopen ALL my projects. due to the number of projects is pretty a lot, that will be kind of annoying to add them back one by one.
I wanna know if there's a smarter way to do that for me.
maybe import all my *.sublime-project
files from folder or something.
thanks
Upvotes: 0
Views: 1103
Reputation: 22791
Short of manually opening every project, I don't think there is any way to do something like this directly. There isn't a command or plugin endpoint that I'm aware of that lets you open a project by name or filename, so it's not possible to create a plugin to do the work, and Sublime doesn't have the ability to pre-load the list of packages directly either.
That said, it is possible to manually update the list of recent projects, but whether or not that is more or less work than opening all of the projects is something to consider.
If you use Preferences > Browse Packages
from the menu or the command palette, a file browser will open on your Packages
folder. From there go up one directory level and go inside of the Local
folder, where you will find a Session.sublime_session
file.
Sublime saves it's state into this file when you quit it, and uses it to restore state when you start it again. Here you will find all of the saved information, such as the windows and files that were open and so on.
Changing this file will change the data that Sublime loads, so you can modify the session file to set up the data that you want. You need to make sure that you modify the file while Sublime is not running or your changes will be ignored and clobbered away. Also it's a good idea to make a backup of the file before you start in case things go pear shaped.
Down near the bottom of the file you will find a top level key named workspaces
, and inside of it a recent_workspaces
key:
"workspaces":
{
"recent_workspaces":
[
"/home/tmartin/local/src/OverrideAudit/OverrideAudit.sublime-workspace",
]
}
This is where the list of recent projects is stored for use in the menu and the quick switch project command. Particular things to notice are that the entries are naming sublime-workspace
files, and that the paths are absolute.
NOTE: On windows, the filenames stored in the session file are in a format like
/C/Users/tmartin
and notc:\users\tmartin
; on that platform you need to make sure that you adjust the paths accordingly. As long as there is already at least one entry in the list when you look at the session file, you can easily see how to construct the paths that you need.
Despite the name of the commands and menu items, what you're actually switching between is different workspaces. Every sublime-project
is associated with a sublime-workspace
file, which acts as a dedicated sublime_session
file for that particular project. This mapping is one-to-many in that you can have multiple workspaces for the same project file, allowing you to reference the same paths in multiple windows but have different window layouts.
While Sublime is not running you can edit this file to add in the full paths to all of your workspace files; when you start Sublime up the list will be populated (every sublime-workspace
file knows what sublime-project
it is associated with).
What remains is whether or not it's quick to come up with the list of files in a way that you can easily paste them into the session file.
Upvotes: 2