Sublime Forum

How to preserve window layout only for projects

#1

I am relatively new to Sublime Text and I am trying to do something that is fairly easy in pretty much every other editor and IDE I use but seems to be very difficult if not impossible in Sublime. I would like the editor to preserve my window layout (ie: open files specifically) when I’m working on projects, and ignore / forget the open files when not working on a project.

Example workflow:

  1. open a Sublime project (ie: from the shell run “subl myproj.sublime-project”)
  2. open a file from within that project (ie: readme.txt)
  3. close the app (ie: mac+q on MacOS)
  4. open an “anonymous” or “non project” instance of Sublime by editing a single file (ie: run “subl other.txt” from the shell)
  5. close the app (ie: mac+q on MacOS)
  6. re-open the previous Sublime project (ie: “subl myproj.sublime-project”)

Expected results:
The Sublime UI should present me with the readme.txt file I had opened the last time I was working on the project (ie: in a single tab), and no other application windows should appear

Actual results:
The actual results different drastically depending on which options you select. For example, if you have remember_open_files set to true and hot_exit set to false you get the following:

  • two instances of Sublime are opened - one for the project selected in the last step, and another containing the “anonymous” project or single-file editor instance that was open in step 4

If, however, you have hot_exit set to false and remember_open_files also set to false then you get the following:

  • only one instance of Sublime will open - the one for the project selected in the last step - but the file that was being worked on for that project (ie: the readme.txt file in my example) is not re-opened

There seems to be multiple issues that impact the workflow I’m aiming for here, including:

  • closing the app (ie: via mac+q on MacOS) does not automatically close the open session / project. As a result the next time you open the app all previously open sessions are restored as well. For example, if you open 2 projects, and then quit the application, then attempt to open a 3rd project, you get 3 independent windows appearing for Sublime, one for the 3rd project you are trying to open and 2 more for the other 2 projects you were working on previously. I can’t see how this would ever be desirable, but maybe there’s a use case for it that I am unaware of.
  • opening the app from the console (ie: “subl other.text”) instantiates some sort of anonymous session or project, even though there is no actual project in use (ie: you can’t use “Project -> Close Project” in this state)
  • the remember_open_files property appears to be applied globally instead of per-project, so when it is turned on it applies to both anonymous sessions and to projects. This seems unusual and non-intuitive to me (ie: why would anyone want to re-open a file that was being edited independently from any project?)

If anyone can help me figure out a good combination of settings, plugins, or whatever might be needed to make this seeming simple workflow work I would appreciate it. Pretty much every other editor or IDE on the market does this automatically without any intervention at all (Visual Studio, VSCode, PyCharm, IntelliJ, etc. etc.) so surely there must be some way to do this in Sublime.

0 Likes

#2

Sublime Text currently doesn’t distinguish between anonymous projects and named projects when it comes to restoring the session.

0 Likes