To recover lost unsaved files in Sublime Text 4 on Windows, Mac or Linux we can follow next steps:
- Don't do any operation with Sublime 4
- Open the location for unsaved files
- Find files
Auto Save Session.sublime_session
Session.sublime_session
- Make a copy of it
- Search for deleted version from the OS
- Restore your files from the
Auto Save Session.sublime_session
Step 1: Sublime temporary files location
The first step is to find the location of the unsaved files for Sublime. It depends on the OS:
Default location MAC
~/Library/Application Support/Sublime Text 3/Local/
Default location Linux
~/.config/sublime-text-3/Local/
Default location Windows
C:\Users\myuser\AppData\Roaming\Sublime Text 3\Local
Step 2: Restore unsaved files from Auto Save Session.sublime_session
Next we need to find the right file and version which could store the unsaved files of Sublime Text.
Using Sublime Text will override those files - so it's better to not use it for a moment.
Auto Save Session.sublime_session
- unsaved filesSession.sublime_session
- file and folder history
Step 3: Recover text files in Sublime
If you are lucky you will find the correct session file.
These are JSON files which store meta data and unsaved files.
Your unsaved files will look like:
"buffers":
[
{
"contents": "python game\nshort text\n",
"settings":
{
"buffer_size": 255,
"line_ending": "Unix",
"name": "python game"
Inside "contents"
you can find the content of your unsaved files.
Sometimes you can directly replace the new file with the backup version. This should recover the older state of Sublime.
Step 4: Enable Auto Backups for Sublime
In order to prevent data loss of unsaved files we can use a plugin: AutoBackups.
The official description of this tool is:
Sublime Text 2/3 Auto backups plugin
AutoBackups is a Sublime Text 2/3 plugin, which automatically save a backup copy every time you save or open (if backup file not exists) a file