Get back unsaved text on your Mac
You closed a tab, the app quit, or you clicked "Don't Save" too fast. Whether the text comes back depends on the app, and on what you did. Start here.
First, stop
Do not open and quit the app again and again. Some apps write their saved tabs when they quit, and can write over what you hope to find. Copy the folder named below to your Desktop first, and look in the copy.
TextEdit
- Open TextEdit again. Windows that were open when an app quits come back the next time you open it, unless Close windows when quitting an application is on in System Settings → Desktop & Dock.
- TextEdit saves your documents as you work on them. For a document you saved once, File → Revert To → Browse All Versions shows the earlier versions.
Sublime Text
- If Sublime Text quit with unsaved tabs, open it again. With its
hot_exitsetting on (the default), it brings them back. - It keeps those tabs in its session file, as plain JSON:
~/Library/Application Support/Sublime Text/Local/Session.sublime_session
- If the tabs do not come back, copy that file and search the copy for a word you remember.
- If you closed the tab and clicked "Don't Save", the text is gone. Sublime Text does not keep a closed tab anywhere.
VS Code
- If you quit VS Code with ⌘ Q, open it again. Its hot exit brings untitled tabs back.
- It keeps backups of unsaved text here:
~/Library/Application Support/Code/Backups
- If you closed the tab with "Don't Save", VS Code deleted the text and its backup. Local History does not help: it keeps only files you saved.
Search for a word you remember
This Terminal command searches the Sublime Text session and the VS Code backups at once. It lists the files that have the word:
grep -rl "a word you remember" "$HOME/Library/Application Support/Sublime Text/Local" "$HOME/Library/Application Support/Code/Backups" 2>/dev/null
Open a copy of each file in a text editor, and look for your text.
Stop it from happening again
The trouble is the untitled tab: text that is safe only until you click the wrong button. A scratch pad that saves as you type has no such moment.
- Scribble Pad saves every sheet to a file while you type, named by the time you started it. There is no "Don't Save".
- Closing a tab, quitting or a restart loses nothing. ⇧ ⌘ T opens the last closed tab. ⌘ P finds any sheet by a word in it.
- To start over, select all and type. The old sheet stays saved, and a new one starts.
- Each sheet is encrypted on disk. Sublime Text's session file is plain text. A Scribble Pad sheet is not.