Sublime Forum

Text file disappeared

#1

Where does Sublime store the text files?

Usually after I close Sublime, when I load it again I find the text in the state I left it.
But when I loaded it this morning, my 9000 words file that took months to write simply disappeared for reasons that I cannot fathom. How could that happen?

Doesn’t Sublime keep the file being written up to date as I go along and store it physically somewhere when it closes, and if so where, so that it be recovered?

Unless there is something I am missing here, this is a very risky program.

0 Likes

#2

Sublime Text stores unsaved file content in a session file, if hot_exit setting is set true.

The file is located at ~/.config/sublime-text/Local/Session.sublime_session on unix systems or in %APPDATA%\Sublime Text\Local on Windows.

ST normally keeps a autosave backup in the same folder to reduce risk of data loss.

However it is grossly negligent not to save important content to normal files, especially when working on it for month! That’s not the application to blame for data loss, IMHO.

see also: Failed Backup + Loss of Unsaved Files

0 Likes

#3

Windows. Sublime is installed in D:\Sublime. There is only a directory Data under it that has a Local directory under it which has only one file: session.sublime_session. Nothing other resembling your specification. I searched.

I agree it was somewhat irresponsible, but I am not used to programs that stay where I closed when I reload-them so that induced some carelessness.

The weird thing is the file has reappeared but if you ask me how, I have no idea – I am unaware of anything I did to recover it. (there was some sort of a second Sublime session open and I had to kill it w. task manager because it kept telling me it can’t close something and after that the file appeared. Do you understand any of this?

Now I will make a txt copy after every change, but to be safe rather sorry, given that I did not find the file you specified can you think of any other place where it might be located?

0 Likes

#4

My statement just assumed a normal setup due to lack of further information. A portable setup uses the Data folder, with exactly the same structure as the ones in user profile do.

Auto Save Session.sublime_session is created regularly while ST is running to ensure having a backup to role back if writing session.sublime_session fails.

That file not being present normally means ST closed normally before without any indication of saving the session file having failed.

If ST crashed during session file writing, the Auto Save Session could still be used to restore information.

There were some issues with automatic updater, which caused session file to currupt during ST upgrades, but those have been fixed in ST4.

Actually, I’ve never experienced any issues with the session file on Windows during the last 10 years of using ST, except in situations my disk ran out of space.

That of course doesn’t mean it can’t happen to others, but it is most likely related with external reasons such as hardware issues, permission issues or antivir programs blocking ST from doing its job.

Hence I wouldn’t second the statement of ST being a risky application.

0 Likes

#5

Thank you for the detailed explanation.

I figured no wp program would fail to create a backup–that would be more irresponsible than the user not saving changes.

I did find that file in the folder I described in the previous msg, but when I tried to open it, it was not readable text, so I did not recognize it as backup. I think I may have messed with trying to open it in Windows, which probably created the second session and made the text appear, that I was forced to close via Task Manager. But I can’t tell what the details were.

So my next question to you is: if smtg like this happens again (which I will prevent by saving after each change), how exactly do I recover the text from from that backup?

0 Likes

#6

I highly recommend using git for these types of workflows. You can stage files, you can commit files, save to a branch. The source control will keep a history of the changes as well as a way to revert back to any previous change. It is a life saver.

Another technique is to never store 9k words in a single file. Write them into separate files. Even a book publisher does not recommend turning in a whole manuscript in a single file.

0 Likes

#7

Sorry to bother you again, but I went over your past answer and it looks like there is something I do not understand.

I have 2 files in the D:\sublime\data\local:

Auto Save Session.sublime_session
Session.sublime_session

created at 10:09 and 10:10.

As far as I can tell they are not straight text, but I can see they contain the text unformatted.

Can you pls explain to an end user: if I need to recover the text, how do I use these files to achieve that?

Thanx.

0 Likes

#8

In case primary Session.sublime_session file got corrupted you can try to replace it with the Auto Save Session.sublime_session while ST is not running.

0 Likes

#9

Looks like “while sublime is not running” may be the key. I will try it later and see if I get a straight text file.

0 Likes