Sublime Text : To The Rescue / Recovering your sublime edits

sublimeJust a sharing here and might be useful if you either accidentally

  • deleted your working file in sublime with no file recovery option
  • multiple times override with no undo options

Before that, let me specify my encounter/scenario
Awhile ago, i created a new workspace and do my coding without adding/ initiating it with GIT.
What happened next gave me a mini heart attack.

I was working on a new phonegap app with many heavy css modifications in it.
Then half way through with fatigue, i worked on another project and then messed up the current project
when i accidentally overwriten and closed the entire sublime workspace.

Panicked, i pressed cmd + Z commands to undo but to no avail. Next, I used recovery software but unable to recover still because that file has multiple overwrites on top. At this point, many of you will sneer on the noob fact of not using GIT & I know, I totally deserve it. Lolx. However,keep in mind that there is possibilities you can messed up still and lost your latest changes /commit in git too,so bad git reflog cant help like when you dont commit, etc.

After much googling and fiddling, here is the solution that recover my sublime 3 text edits.

For Mac users
1) Go to the following path: ~/Library/Application Support/Sublime Text 3/Local/

2) Make backup copy of the files *.sublime_sessions

3) Then,in that file, go to the content part, "contents": "

4) Extract out all the contents portion into a single file. my file was index.html

5) You will notice in the code, common line breaks contain multiple]\n\n.

6) To solve this headache, use sublime 3 search/replace feature by pressing cmd + shift +F. Then in search box key in regex \\n , in replace to input key in \n

Boom! you are done, you would have use your saved coding hours from re-writing the entire code again to be back home doing things like maybe starting a cyber war somewhere or just going gym maybe.

← Previous post

Next post →

1 Comment

  1. You are a king among men! I couldn’t get the session file to open correctly and this saved me. Thanks!

Leave a Reply