Sublime Forum

Have Sublime 3 auto open files

#1

Hello,

Am using Sublime 3.2.2 and would like it to auto open specific remote files upon startup. Or at least autopen every file I had open when I quit Sublime. These files are all remote, and yes the connection to that server is already opened the moment I start my Mac.

I found some solution yesterday, and somehow can’t find today, and I applied it and it worked. Until I shutdown my Mac.

Not sure which file I am supposed to manipulate, nor how, to make this a permanent change,

Thanks

0 Likes

#2

Sublime Text should reopen all previously opened files after restart by default. This behavior is enabled by "hot_exit": true setting in Preferences.sublime-settings.

0 Likes

#3

It is. Also, noticed that file cannot be changed at all.

0 Likes

#4

Which one can’t be changed? The default file in Default.sublime-packages can’t of course, it just contains the defaults. To edit preferences you might want to call Preferences: Edit Settings from Command Palette. The left view contains the mensioned default file which gives you an idea of existing settings, while you need to copy them over to the right view in order to modify them to your needs. The view on the right points to %data%/Packages/User/Preferences.sublime-settings. The location of %data% depends on your setup and OS.

0 Likes

#5

To edit preferences you might want to call Preferences: Edit Settings from Command Palette.

The command pallets does nothing. But I found the file via Mac Finder.

Do I place it anywhere specific in that file? It’s a large file.

Also, do I have to add anything other than:"hot_exit": true,

0 Likes

#6

It should be Preferences: Settings & not Preferences: Edit Settings. Once you type Preferences: Settings in the command palette and press enter on that option, a split window will open.

The left hand side are the default (non editable) preferences and on the right side are your user preferences, where you can copy settings from left side, paste it here and then modify to your liking (based on the options that particular setting can take). Write hot_exit: true in your user preferences, save and maybe restart ST.

1 Like

#7

When I try to save that file, I get the following error:

Error trying to parse settings: Unexpected character, expected a comma or closing bracket in Packages/User/Preferences.sublime-settings:7:1

0 Likes

#8

Actually I got it, forgot the “,” separator

0 Likes

#9

Hello @UltraInstinct05 and @deathaxe

Below is how I have each file set up. As long as I quit and restart Sublime, it behaves as I wish. But once I reboot my Mac, it will not reopen my files that were open when I closed it.

Any help would be appreciated:

Thanks

/Users/sergioq/Library/Application Support/Sublime Text 3/Packages/User
Package Control.sublime-settings

{
	"bootstrapped": true,
	"in_process_packages":
	[
	],
	"installed_packages":
	[
		"MySFTP",
		"Package Control",
		"SFTP",
		"Simple FTP Deploy"
	],
	"hot_exit": true,
}

Package Control.user-ca-bundle

is empty

Perl.sublime-settings

// These settings override both User and Default settings for the Perl syntax
{
	"hot_exit": true,
	"remember_open_files": true,

}

Preferences.sublime-settings

{
	"font_size": 17,
	"ignored_packages":
	[
		"Vintage"
	],
	"hot_exit": true,
}

JSON.sublime-settings

{
	"hot_exit": true,
	"remember_open_files": true,
}
0 Likes

#10

You have hot_exit in too many settings files; it only works in Preferences.sublime-settings (this is not an issue since it will be ignored everywhere else, but I thought I’d point it out).

Previously open files not being open when you restart Sublime occurs when the file doesn’t have any unsaved changes and also no longer exists on disk at the location where Sublime previously thought it was (i.e. it can’t reopen the file if it doesn’t exist).

That sort of thing is very common with files from remote file shares because the files may appear to not exist if the connection hasn’t been re-established.

You mentioned in your original post that your files are remote and that the connection is re-established, so this shouldn’t be occurring. What sort of remote file system are you using? Is it possible that the path to the file on the share changes when your machine reboots? An example might be the sort of automount that doesn’t always use the same mount point. (This is all a shot in the dark, mind you).

0 Likes

#11

You have hot_exit in too many settings files; it only works in Preferences.sublime-settings (this is not an issue since it will be ignored everywhere else, but I thought I’d point it out).

Yes, the call it desperation :rofl:

It’s my own server, on my own LAN, and it’s always on. I am connected to it via SSH. They’re there.

Does the line ““remember_open_files”: true,” have anything to do with it?

Not that I want to do it this way, but is there a file I can set which remote finals to open at startup? That’s kludgy, but still. To have to go through the process of opening 5 different files every time is bit of work.

As well, obviously the Mac rebooting must have. something to do with this, After all, it does work before rebooting the Mac.

0 Likes

#12

I’m not entirely sure that setting even does anything an longer, but I’m not sure. It’s not listed as a default setting any more and I suspect it somewhat predates the hot_exit setting that saves everything.

A plugin can cause files to open every time you start Sublime, but that would get in the way with hot_exit in general without some extra cleverness which may or may not be easy (I’ve never tried it myself).

It definitely seems weird that a reboot does it; have you verified with some other editor that the files are still there with the same name after a reboot but before you start Sublime for the first time?

0 Likes

#13

It definitely seems weird that a reboot does it; have you verified with some other editor that the files are still there with the same name after a reboot but before you start Sublime for the first time?

It just’s me and my Mac, behind our own firewall. Yes, there’s a PC here, but it’s not used for anything coding wise. That’s it. :man_shrugging:

0 Likes

#14

@deathaxe @UltraInstinct05 The only other hint, when I startup Sublime, my SFTP menus are greyed out the first time.

Maybe I need a startup script that connects to the server automatically? Don’t know if that’a thing for Sublime. My Mac is already connected to my server before I even startup sublime.

0 Likes

#15

It’s common for menus that trigger plugin commands to be greyed out right when you start Sublime because Sublime starts up and makes itself available for editing while plugins are still loading; commands that don’t exist yet are greyed out in the menu, and until the package finishes loading the commands technically don’t exist.

Just to clarify here, my assumption based on your initial posts is that you have a remote file system mounted to your machine at startup (like an ssh file system, or nfs, or cifs, etc) that makes remote files appear to be local files.

Is that the case, or are your remote files being edited by the SFTP package? If it’s the SFTP package, perhaps you have a configuration issue there; it can operate in a couple of different ways, so potentially if it was configured to download files as you open them and then re-upload them on save, it could be storing them as temporary files which get cleared away when you reboot, making Sublime think they no longer exist.

0 Likes

#16

are your remote files being edited by the SFTP package? If it’s the SFTP package

It’s a remote server running Ubuntu, and yes, I use SFTP to edit them. Something is up with the SFTP package however, and that’s not a sublime issue. So I put in a tech support request Codex. My never responded to tech support ticket is below.

Hello,

Am using Sublime ver 3.2.2 with your SFTP package and I have recently switched to Mac, MacBook Pro os Catalina 10.15.7.

Every once in a while, more frequently in the past few days, I go to save, and it asks me if I want to buy the SFTP package. Hitting ESC and saving again works.

But it gets annoying, throws off my rhythm, and I worry it might be a sign of something else.

I’ve just turned on the debugging mode, so have no info, but thought you might be familiar with this problem already.

Thank you,

0 Likes

#17

Your license key for the SFTP package is stored in your SFTP settings; it sounds like it might have gone missing. You should be able to use Preferences > SFTP > Settings from the menu and then include lines like the following (with your own email address and license key):

    "email": "someone@somewhere.com",
    "product_key": "xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx",
0 Likes

#18

All I can find in the menus is an option to enter the license key. I’d rather look at the file first, see if it’s ok. Because it does work off and on.

0 Likes