Sublime Forum

[MacOS] I want my tabs to be reopened automatically even if application was closed

#1

I’ve just got my first MacBook after years of using Linux.

The behavior on Linux I got used to:
When I click the “close” button in the top corner ST doesn’t ask me to save files and restores all the tabs including those not saved and it doesn’t ask me to save files.

The same behavior is reachable by closing the window by Cmd-W but I close ST by clicking on the red button that imitates Cmd-Q, not Cmd-W. Therefore, There are no chances to get my tabs back on the next launch.

How to make ST behave as on Linux or Cmd-W on clicking a red button?

1 Like

#2

Sublime behaves the same way on all platforms; if you close a window that has a project associated with it, you can recall that project later and get state back, and when the application exits the state of everything (all windows and their state) is saved and restored back.

The distinction is that on MacOS applications don’t exit when you close the last window; they keep running in the background so that you can create a new window without waiting for the application to restart.

From your problem, it sounds like you’re running afoul of this; closing the window does just that, which does the same thing that it would have done on Linux except that if it’s the last window, then on Linux that would terminate the app and on MacOS it just closes the window.

This is just a fundamental difference to how MacOS operates; short of using a project for everything, if you want this behaviour on MacOS you need to get into the habit of quitting the application when that’s what you meant to do.

2 Likes

#3

As @OdatNurd said, this is more of a macOS design philosophy side-effect than a SublimeText issue. You will encounter this same behavior in many other apps. Preview to only site one.

Something that can get you closer to a Windows-like behavior, where closing the last window of an application actually quits it, can be reached using RedQuits.

Sadly, it still closes the window before quitting, therefore I will not restore it when relaunching the application like it would when quitting with Cmd + Q.

0 Likes

#4

If you still forget to close the application every time with Cmd+q, I have a solution: turn off creating new tab while launching application.

	"create_window_at_startup": false, // so that no tab is created when launching from anywhere, then last session is not overridden

The problem is that while launching the application while it’s still running, will create a new tab, and the file storing the last session info is lost. So ST will have no clue what files were open. Preventing it from creating a new tab will keep that file intact, and you can restore the last open files with Cmd+Shift+T. It is a remedy for emergency cases, even it needs several more strokes

0 Likes

#5

cmd+shift+t does not work when there are no windows open. It can’t restore the last open files.

0 Likes

#6

I have the same problem. Behavior is not the same.

Let’s say I have one tab open, not saved, with some text on it. When I hit the close button, ST asks me if I want to save my file. I come from windows, behavior there is not asking anything and restoring my tab next time I open ST.

0 Likes

#7

See OdatNurd’s explanation above: [MacOS] I want my tabs to be reopened automatically even if application was closed

macOS simply behaves differently to Windows. This is standard platform behavior.

0 Likes

#8

As a long-time Mac user - I concur with bschaaf and OdatNurd. This is the way Mac’s work. For me, this OS behaviour is sensible and logical, and I always need to check myself on those rare times I use Windows. It is all what you are used to, I guess, but when you’ve been using Mac’s for a while, it feels very natural.

If you quit the app without saving (CMD + Q), the next time you re-open ST all your open tabs (both saved and unsaved) will appear in exactly the state that you left them. Again, for me this feels intuitive and Mac-like

0 Likes