To get back an earlier version of a TextEdit document, open it and choose File, Revert To, Browse All Versions. You don't need Time Machine for this: Apple's Mac User Guide says apps like TextEdit save versions automatically while you work, and when you open, save, duplicate, lock, rename or revert a document. Pick a version on the timeline and click Restore, or hold Option and click Restore a Copy to keep both. Apps of your own can use the same version store through NSFileVersion; a test below saves, lists and restores versions of a file.
SWIFT TIPS · MAC · FILES
First posted on July 24, 2019, as "Revert data Or get back data .txt in macbook". Rewritten on November 19, 2026. The NSFileVersion test was run on a Mac with Swift 6.2.3 (Xcode 26.2) on macOS 26.0.1, on a scratch file made for the test, and its stored versions were deleted at the end. The menu steps are from Apple's Mac User Guide.
In 2019 I lost text in a TextEdit file and wanted the earlier content back. The post showed the steps: the current file, then File, Revert To, Browse All Versions, and picking the version on the right side of the screen. It called this "time machine", because the version browser looks like Time Machine.
The steps are right, and they work even without a Time Machine backup. This rewrite explains where those versions come from, what each button does, when versions won't help, and how a developer can use the same feature in an app.
Where the versions come from
Apple's Mac User Guide page on past versions says that many apps save versions of a document automatically as you work, about every hour or more often when you're making many changes, and that a version is also saved when you open, save, duplicate, lock, rename or revert a document. TextEdit is one of those apps. macOS keeps these versions itself, apart from Time Machine; the test further down saved and restored versions without any backup step.
Restoring a version
- Open the document in TextEdit.
- Choose File, Revert To, Browse All Versions.
- Click the tick marks along the timeline on the right to step through versions. The current document stays on the left.
- Then choose one of these, as Apple's guide describes them:
- Restore replaces the document with that version.
- Restore a Copy, shown when you hold the Option key, puts that version in a new document and leaves the current one alone. That's the safe choice when you're not sure.
- Done leaves the document as it is.
The Revert To menu also has a shortcut back to the last opened version, which undoes everything since you opened the file.
When versions won't help
- The app doesn't save versions. Many text editors and code editors don't use this feature. For those, Time Machine or Git is the safety net.
- The file was replaced, not edited. Versions follow a document. A file overwritten by a download or by another app may not have a useful history.
- Copies elsewhere. I haven't tested what happens to a document's versions when it's copied to another Mac or a USB drive, so don't count on them there.
For anything you'd hate to lose, a backup is still the real protection; versions are for undoing your own edits.
The same feature in your own app
Document-based apps get versions through the document classes, and NSFileVersion gives direct access to the version store. This test wrote a scratch file, saved a version, overwrote the text, saved another version, listed the versions, restored the first, and then removed the stored versions:
File now: "Overwritten by mistake"
Stored versions: 2
After restoring the first version: "Go back time machine"
Stored versions after cleanup: 0
The calls are NSFileVersion.addOfItem(at:withContentsOf:options:) to save a version, otherVersionsOfItem(at:) to list them, replaceItem(at:options:) on a version to restore it, and removeOtherVersionsOfItem(at:) to clean up, which the test used so it left nothing behind. In an app built on NSDocument, macOS manages these versions for you, which is how TextEdit gets its Browse All Versions screen.
A quick check for your Mac
- Open a document you edit often in TextEdit or Pages and look at File, Revert To. If Browse All Versions is there, its history is being kept.
- Check that Time Machine, or another backup, is set up for files that matter.
- For code, use Git; it keeps history independent of any app.
What the 2019 version said
The post showed the document, the menu, and the version browser:



Keep reading on JR Devhub
Comments