Sublime Forum

Disable feature that brings up latest files opened in previous session?

#1

Just started using ST3 and I noticed that whenever I fire it up it automatically opens up windows or panes for each file that was still open when I quit the program. Is there a way to disable this feature?

Thanks.

0 Likes

#2

The setting hot_exit controls that. As seen here, it’s turned on by default, so you need to override it in your user settings.

    // Exiting the application with hot_exit enabled will cause it to close
    // immediately without prompting. Unsaved modifications and open files will
    // be preserved and restored when next starting.
    //
    // Closing a window with an associated project will also close the window
    // without prompting, preserving unsaved changes in the workspace file
    // alongside the project.
    "hot_exit": true,
0 Likes

#3

Thanks! One more question…
I notice that ST keeps track of currently opened file and re-opens them every time I open a new ST session. For example I have multiple screens in my window manager, and if I’m in one screen and open up a.foo and b.bar (“sublime_text a.foo b.bar”)…
and then in another screen open up c.cat (“sublime_text c.cat”) , in that 2nd instance it’ll have 3 files open: a, b and c.

Is this a separate setting?

0 Likes

#4

Boy I hope there is a way to disable this… it’s becoming very annoying. I have a 3x3 grid of workspaces where I have various projects being developed in each one and typically fire up a text editor in each one as I’m jumping from project to project. By the time I get the the 9th screen and open the editor I end up with a slew of files and also the same file opened in every instance of ST. :frowning:

0 Likes

#5

From the command line, just using e.g. sublime_text file.txt will either start Sublime running (in which case hot_exit controls if you get your old session back or not) or open file.txt in the most recently accessed Sublime window. To always create a new window, you can use sublime_text -n file.txt instead.

That said, when you do this, do you end up with two windows on two different desktops that both have three files open, or is it pulling the window from the first desktop to the second one and opening the file there?

Here on this Linux machine if I don’t use -n, the window manager pulls the most recently active Sublime window from the other desktop to the current one when it opens the file. On my MacOS machine not using -n makes the current workspace switch to the one that Sublime is running in before opening the file. I don’t have any windows machines with multiple desktop support enabled to test with, though.

0 Likes

#6

Ok here’s what I’m seeing…

sublime_text a.txt
(opens up “a” by itself in a new window)

sublime_text b.txt
(opens up “b” by itself in a new window)

Now I have 2 windows open, each with different files… this is good.
Here’s where it gets wierd…

(start over)
sublime_text a.txt
(opens up “a” by itself in a new window)
make an edit to “a” and save the file, but keep the editor open

sublime_text b.txt
(opens up a new window with “a” in one tab and “b” in another)

So it seems if I make a change to the file it sets a flag so that if I open up another instance of sublime, not only will any files indicated on the command line come up, but so will another copy of that recently saved file.

If after saving “a” file I then use the -n flag when opening up “b”, sublime opens up “a” and “b” in new separate windows. So now I have 2 windows of “a” and one of “b”

1 Like

#7

This is happening with me too. Kindly provide the solution if you’ve fixed it…
Thanx

0 Likes

#8

Looks like something was added to Sublime in the recent years that addresses this:

    // When files are opened from a file explorer or from the command line, this
	// controls whether a new window is created or not.
	// - "never": Never open a new window unless no window is open.
	// - "always": Always open files in a new window.
	// - "finder_only": (macOS only) Only open files in a new window when
	//                  opening them from finder or dragging onto the dock icon.
	//
	// On Mac, this value is overridden in the platform specific settings.
	"open_files_in_new_window": "never",

Setting the value to ‘never’ solves this problem.

0 Likes