Sublime Forum

Please help me understand how to save and restore Projects simply/reliably

#1

Most of the threads I could find on this are 10+ years old. I’m using ST4 build 4200 on macOS 15. I haven’t used “Projects” before but I need to start. I’m finding it extremely frustrating and borderline useless.

Someone please help me understand this… I assume I’m just using it wrong.

  1. I save a Project, then accidentally close one of the open files/tabs. Poof, that file is no longer part of the project. Projects appear to auto-save. No warning, no confirmation. So, if I later re-open the project, that file is no longer opened. If I close ALL of the tabs by mistake, then all of a sudden I have a completely empty project. I’d much prefer to manually save a project in a known-good state, allowing me to revert/restore to that fileset and layout later regardless of what I’ve done since the save.
  • I have hot_exit disabled, with the following in my settings:
    "hot_exit": "disabled",
    "hot_exit_projects": false,
    
  1. It’s been asked many times but I don’t see any recent answers: is there any way to save a portable project file as a single file, vs 2 separate .sublime-project and .sublime-workspace files?

I’ve seen some people suggest the ProjectManager package, but not sure that will solve these. I’m also wary of loading a 3-year old package just to solve what I assume may be just a problem with how I’m using this feature…

Thank you kind souls for any guidance :pray:

0 Likes

#2

Maybe a good start to learn about projects may be https://docs.sublimetext.io/guide/usage/file-management/projects.html - and the target to update in case we find something missing to understand projects.

The very fundamental task of a sublime-project file is to save the list of folders, which have been added to sidebar.

On top of that project-specific settings can be added to override global defaults.

It may also contain project-specific build configurations.

A project is never auto-saved by ST. It may be modified by plugins however. It only contains configuration, but no state.

To create a protable project, place a sublime-project file into a folder and let it point to ..

{
    "folders": [
        {
            "path": "."
        }
    ],
    "build_systems": [],
    "settings": {},
}

Note: A project isn’t designed to hold lists of individual files scattered around on filesystem.


A sublime-workspace file stores state of your project’s window - open files, search history, etc.

It stores all open files, regardless where they are located - in one of the project’s folders (in sidebar) or anywhere else. Once those external files are closed, they are no longer associated with a workspace and thus can’t be reopened beyond what “Reopen closed file” command can do.

For open files/tabs to be restored you probably want to set “hot_exit_projects”: true`.

Theoretically a project can have multiple sublime-workspace files containing snapshots of its state, but I’ve actually never used that feature. Check out “Save Workspace as…” to backup desired state of your project’s window.


Project Manager is a possible way to organize many sublime-project files in Packages/User folder regardless where associated folders are located. It helps keeping organized if you whish to separate project files from actual filesystem folders. FWIW, it is one of my favorite must have plugins.

Basically, it is an alternative for ST’s built-in Quick Switch Project command.

I personally also use AutoProjects, which creates a .sublime folder containing a project for each folder opened in ST. This way there’s a location to store windows’ state automatically, in case they are closed accidentally. It mimics VS Codes behavior to some degree.

0 Likes

#3

Ok, thanks. That helps clear up one major misconception I had then. I don’t really often use the “everything for a project in one folder” for the type of things I work on. They are files scattered around, some temporary, some permanent, some on cloud storage and some local.

So what I really needed was a way to just say “save all of these open editors so I can reboot my computer and come back to work on them in a few hours/days/whatever”. Does that exist either natively somehow or with a plugin?

0 Likes

#4

Hot exit does that, it’ll restore everything how it was. You can also save a workspace (*Project > Save Workspace As…), though again you’ll need to have hot exit enabled for projects.

0 Likes

#5

@bschaaf Thanks but if I enable hot exit, then accidentally close a tab, there’s no way to get back to where I was, right? I am looking for a way to say “remember this set of 7 open files” and then be able to re-open those exact 7 files at a later time, regardless of whether I have closed 3 of them, or opened 6 others.

0 Likes

#6

In that case you’re looking for a workspace. And for accidentally closed files you can simply reopen them (File > Open Recent > Reopen Closed File).

0 Likes

#7

Thanks for trying to help. I think what I’m looking for is more like an “immutable workspace” - when I just tried to save e.g. a set of 7 files to a workspace, and then close all of the tabs, as soon as I went to re-open the workspace by double clicking it, Sublime gave me an error: “Unable to read project…” (I never saved a project? just a workspace?)

image

When I went to try to inspect that file (I know it’s just a .JSON file) ironically I couldn’t use Sublime for the task. So I opened it in VSCode. It was a 1200+ line file containing lots of stuff that I wasn’t expecting- recently open files, search history, etc. But no trace of those 7 files that I actually wanted to be in there.

I found this Session Manager package which is “pretty close” to what I wanted. Not sure what I’m doing wrong when it comes to the built in workspace feature.

0 Likes