Tutorials 25 min read

You Deleted It From the Note. The Undo File Kept It.

MMNMNOTE
undovimvs-codeobsidianprivacyplain-texthow-to
Updated October 2, 2026

If your editor can undo after a restart, it keeps a second record of your note on disk — and that record still holds the text you deleted. Deleting a line from the note does not delete it from the history file. Find where each tool keeps that file, decide per folder, and delete it on purpose.

Here is the test, run on 28 September 2026 with Vim 9.1 and a clean configuration. Make a two-line note. Add a line with a fake Wi-Fi password and save. Delete the line and save again — then look at the folder.

D=$(mktemp -d) && cd "$D" && printf 'Shopping list\nmilk\n' > note.md
vim -u NONE -i NONE -N -es -c 'set undofile undodir=.' -c 'call append(1, "wifi password: hunter2-DEMO")' -c 'w' -c 'q' note.md
vim -u NONE -i NONE -N -es -c 'set undofile undodir=.' -c 'g/hunter2-DEMO/d' -c 'w' -c 'q' note.md
grep -c hunter2-DEMO note.md          # 0 — the note is clean
ls -la                                 # a hidden .note.md.un~ sits beside note.md
strings .note.md.un~ | grep hunter2    # wifi password: hunter2-DEMO

The note is 19 bytes and holds no password. Beside it sits a hidden file, .note.md.un~, about 1 KB, and strings still finds the line. Reopen the note in Vim, press u, and the password comes back.

That file exists because persistent undo was switched on — set undofile in the commands above. Vim's reference manual lists 'undofile' as (default off).1 Turn it on and leave 'undodir' at its default of ".", and the file lands next to the note. In the manual's words: "The undo file name for "file.txt" is ".file.txt.un~"."1 The manual is just as plain about its lifetime: "NOTE: undo files are never deleted by Vim. You need to delete them yourself."2

The question surfaced on Hacker News on 27 September 2026, in a thread that had 347 points and 310 comments the next day.3 One commenter put the worry directly — "If I delete something I consider sensitive, I might unwittingly be recording that presumed-deleted piece of data to my user profile somewhere to be deleted never."4

Everything below is as documented by each tool's maker on 28 September 2026.

The single habit: treat editor history as a second copy

The habit is to treat any history your editor keeps across restarts as a second copy of the note, with its own location, its own lifetime and its own delete button. The note and its history are separate files. Editing one does not edit the other, and deleting a line from one leaves the other alone.

Our guide to keeping a version history of your notes calls undo "a volatile session buffer that empties when you close the app." By default, that holds for undo itself. Switch on persistent undo in Vim or Neovim or File recovery in Obsidian, or leave VS Code's local history at its default — and it no longer does. The history is built to outlive the session.

VS Code is the one that starts switched on. Its March 2022 release notes list workbench.localHistory.enabled with "(default: true)", and the current source still ships 'default': true.56 Saving adds an entry, and "Each local history entry contains the full contents of the file at the time the entry was created".5

Two copies means two things to delete.

The Linux convention agrees that this is data — not clutter. The XDG Base Directory Specification describes state as the "current state of the application that can be reused on a restart (view, layout, open files, undo history, …)" and keeps it apart from the cache directory, which is for "user-specific non-essential data files".7 Undo history is on the state list — not the cache list.

Where Vim, Neovim, VS Code and Obsidian keep it

Each tool keeps its history in a different place: Vim beside the note once persistent undo is on, Neovim in a state folder under your home directory, VS Code in its user data folder, and Obsidian in its global settings outside the vault. Only VS Code documents its history as on by default.

The table is a map — not a ranking. Every cell comes from the maker's own documentation, read on 28 September 2026.

Tool and featureOn by default?Where it livesWhat it holdsHow much, how long
Vim — persistent undoNo1Beside the note as .name.un~, while 'undodir' stays "."1The undo history, deleted text includedUp to 1,000 changes on Unix, VMS and Windows1; never cleaned up by Vim2
Neovim — persistent undoNo8~/.local/state/nvim/undo//9The undo history, in Neovim's own file formatThe same settings as Vim
VS Code — local historyYes56The local user data folder5Full file contents, one entry per save550 entries per file; files up to 256 KB56
Obsidian — File recoveryNot stated in its help pageGlobal settings, outside the vault10Full file contents, .md and .canvas10Snapshots at least 5 minutes apart, kept 7 days; both configurable10

Placement is the part most people miss. A history file beside the note travels wherever the folder goes — into every sync of that folder and every copy in your 3-2-1 backups. A history file elsewhere does not — which protects it from a lost folder and hides it from you.

Obsidian's help page says snapshots "capture the full content of your files, not just changes."10 They are "kept in the Global settings, outside of the vault, to account for vault-related data loss" — so "snapshots are stored with the absolute path to the note."10 The page is also clear that "File recovery snapshots will not sync between devices."10

Each device keeps its own copy.

VS Code's limits cut both ways. The 50-entry cap discards "the oldest entries" once a file passes it.6 The 256 KB size limit — the default at launch, and still the default in the current source — sits far above the size of a typical note.56 Most notes are small enough to be copied every time.

Voided is not deleted

When a note changes outside Vim — a sync client, a script, an AI agent, another editor — Vim stops using the undo file, but opening the note does not remove it. Your undo history is gone from the editor; the text you deleted is still on disk. Losing the history and erasing the text are two different events.

Vim's manual describes the check: "Vim will detect if an undo file is no longer synchronized with the file it was written for (with a hash of the file contents) and ignore it when the file was changed after the undo file was written, to prevent corruption."2 Any byte changed by another program is enough — the history stops working at once.

The same test shows it. Append one line to the note from outside Vim, then reopen it.

echo "added by another program" >> note.md
vim -u NONE -i NONE -N -es -c 'set undofile undodir=.' -c 'undo' -c '%p' -c 'q!' note.md
# Vim: no warning by default; the undo file is ignored silently
# u:   Already at oldest change
strings .note.md.un~ | grep -c hunter2-DEMO   # 1 — ignored, not deleted

Vim says nothing — u simply reports "Already at oldest change." The manual notes that while reading files with 'undofile' set "most errors will be silent, unless 'verbose' is set."2 Only with 'verbose' on, or after an explicit :rundo, does Vim show "File contents changed, cannot use undo info."211 The undo file was the same size afterwards, and strings still found the password. Vim also ignores an undo file whose owner differs from the note's owner, unless the undo file belongs to you — and that, too, leaves the file where it is.2

This is why undo seems to vanish after a sync. The sync client rewrote the note — so the hash no longer matched. The history is unusable. The deleted text is still readable.

It stays readable until the next time you save that note in Vim. With 'undofile' on, that write deletes the stale undo file first, then writes a fresh one that holds only the new session's changes — or none at all, if there is nothing to undo.11

The pattern is not special to editors. AI coding tools keep full session copies on disk, and a search index can keep a note you deleted. Derived files outlive the thing they were derived from.

Encryption is the one documented exception. "When the file is encrypted, the text in the undo file is also encrypted," the manual says.2 Then: "The same key and method is used."2 That applies only to a note encrypted with Vim's own encryption. A plain note gets a plain undo file.

When another tool decides the history is a cache

The other way history ends is that something deletes it. Vim never cleans up old undo files on its own, so the risk comes from another program that shares the folder and treats the file as disposable or unreadable. Two editors pointed at the same undo folder can destroy each other's history just by saving.

Vim's own manual documents both halves. When an undo file comes from a newer Vim, error E824 gives a warning — "Don't write the buffer if you want to keep the undo info in the file."2 And writing an undo file is not an edit in place. The manual's note on :wundo says so — "Overwriting happens by first deleting the existing file and then creating a new file with the same name"2 — and Vim's source takes the same delete-then-create step when it saves an undo file on an ordinary write, whenever the old file looks like an undo file.11

Here is one person's account. David Chisnall, who says he has used Vim since around 2000, wrote on Mastodon in August 2026 that he tried Neovim "when it was quite new." In his telling: "It had just noticed the existence of a vim undo file, deleted it (losing all of the data in it) and replaced it with one that vim couldn’t read."12 He had set his undo path under ~/.cache himself.12 His original report has not been found.

The defaults do not collide. Vim writes beside the note and Neovim writes to its own state folder — so the two meet only when you point them at the same place.19

The fix is one folder per program.

Marcin Wichary quoted the account almost in full on his blog Unsung. He tied it to Jef Raskin's First Law, quoting it from Raskin's 2000 book The Humane Interface — "A computer shall not harm your work or, through inaction, allow your work to come to harm."13

The folder name matters too. ~/.cache is, by the XDG definition, for "non-essential data files".7 Undo history belongs under state — where tools that empty the cache will leave it alone.

The five-minute version

The five-minute version is seven steps and needs no new software. Check whether each tool keeps history, find the files, decide which folders deserve it, exclude the rest, and delete what already exists. Turning a feature off is not the same as deleting what it stored — so step five is not optional.

  1. Check whether it is on. In Vim or Neovim, run :set undofile? and :set undodir?. In VS Code, search Settings for workbench.localHistory.enabled. In Obsidian, open Settings → Core plugins → File recovery.
  2. Find the files. find ~/notes -name '.*.un~' lists Vim's. Neovim's sit in ~/.local/state/nvim/undo/ by default. VS Code shows local history in the Timeline view.5 Obsidian lists snapshots under File recovery → View.10
  3. Decide per folder. Drafts benefit from history — a folder that holds passwords, health notes or names does not.
  4. Exclude the sensitive folders. Vim takes an autocommand; VS Code takes workbench.localHistory.exclude.25 Obsidian documents no per-folder exclusion.
  5. Delete what is already there. Switching the feature off leaves existing history in place in both Vim and VS Code.16
  6. Give each editor its own undo folder. Never point two programs at one path — a save in one can erase the other's.2
  7. Re-check after any new sync client, agent or editor. Each can void or delete history without asking.

Steps 4 and 5 carry the privacy weight. The next section takes them tool by tool.

The thirty-minute version

The thirty-minute version is the same method, tool by tool, with the exact settings and commands each maker documents. Vim and VS Code let you exclude a path and delete what exists. Obsidian lets you clear everything at once. Neovim follows Vim's settings with a different folder and its own file format.

Vim. The option does not clean up after itself: "When 'undofile' is turned off the undo file is NOT deleted."1 The manual's own exclusion example is au BufWritePre /tmp/* setlocal noundofile.2 Swap in the folder you want kept out of history — then list and remove what is there:

" in your vimrc: no undo file for anything under ~/notes/private
au BufWritePre ~/notes/private/* setlocal noundofile
find ~/notes -name '.*.un~' -print     # review the list first
find ~/notes/private -name '.*.un~' -delete

Neovim. Its default undo folder is $XDG_STATE_HOME/nvim/undo// — ~/.local/state/nvim/undo// on a typical Linux setup.89 The same autocommand works.

Neovim's own file format has changed before. Merging a format change in March 2021, the maintainer bfredl wrote: "New versions of neovim will not read undofiles written by nvim before this merge."14 His advice for an upgrade — "so if you worried about unsaved changes lurking around in undofiles it would make sense to keep such version around somewhere to recover them."14

An undo file lasts only as long as its format does.

VS Code. Exclusion is a glob map, and deletion is a command. The shipping description for both settings carries the same warning: "Changing this setting has no effect on existing local file history entries."6

{
  "workbench.localHistory.exclude": {
    "**/private/**": true
  }
}

Then run workbench.action.localHistory.deleteAll — "Delete all history entries across all files."5 Entries for the rest of your work go with them — so decide first.

Obsidian. There is no documented per-folder switch. Settings → Core plugins → File recovery → Clear removes every snapshot, and the help page warns: "Clearing the snapshot history irreversibly deletes all snapshots in your vault."10 Otherwise, snapshots expire on the retention window — 7 days unless you change it.

Snapshots are also device-specific, so clearing them on one device does not clear another's.10

What deleting the history does not do

Deleting a history file removes it from the folder. It does not guarantee the bytes are gone. Copies can survive in backups taken before the delete, in a sync service's version history, and on solid-state drives that write new data elsewhere rather than over the old blocks.

Treat the delete as the first step, not the last. If a password landed in a note, change the password.

Permissions vary too. In the test above, the undo file had the same permissions as the note, but that was one run on one system.

Common mistakes

Most mistakes here come from treating the note as the only copy. Five are common enough to name. Each one either leaves deleted text on disk longer than you think, or loses history you meant to keep. Every item below points back to a documented behaviour, not to a guess.

The first two leave text behind. The last two lose it.

Keep the history you want, on purpose

Undo history across restarts is a convenience that also stores what you removed. If you want a durable record of a note's past, keep one deliberately — a dated, named history you control — and let undo stay short-lived. The two jobs are different, and the tools for them should be too.

Chisnall's post describes the convenience well: "ooops, I deleted something from this file, maybe last week and one reboot ago, what was it? Undo until I find it, copy it, paste it into the current version."12 That is a real use — and many people will want to keep it.

The question is where.

For drafts, keep it. For anything sensitive, the version history guide shows how to keep a history you choose — committed, dated and visible — instead of one your editor keeps for you.

Frequently asked questions

The first four questions come from the Hacker News thread, quoted as they were asked. The rest are the searches people run after deleting something they should not have typed. Each answer points to the maker's own documentation or to the test above, and everything is as documented on 28 September 2026.

"is vim encrypting this data it keeps forever?"

Only if the note itself is encrypted with Vim's own encryption. Vim's manual says that "When the file is encrypted, the text in the undo file is also encrypted," using the same key and method.2 A plain note gets a plain undo file, and Vim never cleans it up.2 The question was asked on Hacker News.4

"I wouldn’t want a text editor to persistently store a copy of everything I type without my consent."

In Vim and Neovim, persistent undo is off until you turn it on.18 VS Code's local history is on by default and stores the full file on each save — per save, not per keystroke.56 Obsidian's help page does not say whether File recovery starts enabled. The comment was posted on Hacker News.15

"AFAICT neither has any default for undodir"

Both do. Vim's 'undodir' defaults to "." — the note's own folder — and Neovim's defaults to $XDG_STATE_HOME/nvim/undo//.18 That difference is why the two editors do not collide unless you point them at the same place. The comment was posted on Hacker News.16

"If you’re storing your important data in ~/.cache, you’re eventually going to suffer even if you don’t install Neovim."

The XDG specification agrees in spirit. It reserves the cache folder for "non-essential data files" and lists undo history as state.7 If you keep undo files and care about them, put them under state, not cache. The comment was posted on Hacker News.17

Is text I deleted still in my undo file?

Yes, until the undo file is deleted. In a test with Vim 9.1 on 28 September 2026, a line deleted from a 19-byte note was still readable in the hidden .note.md.un~ beside it, and u restored it after a restart. Vim does not clean up undo files itself.2

Why did my undo history disappear after a sync?

The sync client changed the note, so its content hash no longer matched the undo file — and Vim ignores a mismatched file.2 The file stays on disk with the deleted text in it until you next save that note in Vim, which deletes the stale file. The history is lost to the editor, not erased from the folder.

Where does VS Code keep local history, and how do I delete it?

In the local user data folder, up to 50 entries per file.56 The command workbench.action.localHistory.deleteAll deletes all entries across all files.5 Turning local history off does not remove existing entries.6

Do Obsidian's File recovery snapshots sync to my other devices?

No. The help page says snapshots "will not sync between devices" and are kept outside the vault, stored with the note's absolute path.10 Clearing them is irreversible, and because they are device-specific, it clears only the device you run it on.10

Two files, two deletes

An editor that remembers undo after a restart keeps a second copy of your note, and the text you deleted lives in it. Find where each tool keeps it, keep history where it helps, exclude it where it does not, and delete what is stored on purpose — because turning the feature off leaves it there.

Deleting a line edits the note. Only deleting the file edits the history.


The habit of knowing where your text lives applies to every tool, and mnmnote.com keeps notes as open Markdown, stored locally on your own device.

Footnotes

  1. Vim reference manual. "options.txt" — 'undofile', 'undodir', 'undolevels'. Vim 9.2, last change 26 September 2026. https://vimhelp.org/options.txt.html. Accessed 2026-09-28. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11

  2. Vim reference manual. "undo.txt" — section 5, "Undo persistence." Vim 9.2, last change 14 February 2026. https://vimhelp.org/undo.txt.html. Accessed 2026-09-28. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13 ↩14 ↩15 ↩16 ↩17 ↩18 ↩19 ↩20

  3. Hacker News. "On caring for user data: NeoVim caused Vim undo files to be deleted," item 49867067, 27 September 2026. https://news.ycombinator.com/item?id=49867067. Accessed 2026-09-28. ↩

  4. luma. Comment on Hacker News item 49867067, 27 September 2026. https://news.ycombinator.com/item?id=49867949. Accessed 2026-09-28. ↩ ↩2

  5. Visual Studio Code. "March 2022 (version 1.66)" release notes — "Local history." https://code.visualstudio.com/updates/v1_66. Accessed 2026-09-28. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13

  6. Microsoft. src/vs/workbench/browser/workbench.contribution.ts, microsoft/vscode, commit 457595176bc1 (file last changed 2026-09-23). https://github.com/microsoft/vscode/blob/457595176bc1230720055057ff43b6887842e3b7/src/vs/workbench/browser/workbench.contribution.ts. Accessed 2026-09-28. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11

  7. freedesktop.org. "XDG Base Directory Specification," version 0.8, 8 May 2021. https://specifications.freedesktop.org/basedir/latest/. Accessed 2026-09-28. ↩ ↩2 ↩3 ↩4

  8. Neovim user manual. "Options" — 'undofile', 'undodir'. https://neovim.io/doc/user/options/. Accessed 2026-09-28. ↩ ↩2 ↩3 ↩4

  9. Neovim user manual. "Differences between Nvim and Vim" (vim_diff). https://neovim.io/doc/user/vim_diff/. Accessed 2026-09-28. ↩ ↩2 ↩3

  10. Obsidian Help. "File recovery." https://obsidian.md/help/plugins/file-recovery (source: https://raw.githubusercontent.com/obsidianmd/obsidian-help/master/en/Plugins/File%20recovery.md). Accessed 2026-09-28. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11

  11. Vim source. src/undo.c, u_write_undo() — "If the undo file already exists, verify that it actually is an undo file, and delete it" — called from src/bufwrite.c when a buffer is written with 'undofile' on; with no undo information it stops "after deleting any existing undo file" (L1663–1670). u_read_undo() shows "File contents changed, cannot use undo info" only when 'verbose' is set or a file name was given, as with :rundo (L2000–2011). vim/vim commit e41756455701 (file last changed 2026-08-26). https://github.com/vim/vim/blob/e41756455701b9419f2493ab2e2e0f01557fe939/src/undo.c#L1614-L1670. Accessed 2026-09-28; re-checked 2026-10-03. ↩ ↩2 ↩3 ↩4 ↩5

  12. Chisnall, D. Post on Mastodon (infosec.exchange), 28 August 2026. https://infosec.exchange/@david_chisnall/117171776562702259. Accessed 2026-09-28. ↩ ↩2 ↩3

  13. Wichary, M. "'They had no concept of a duty of care to their users.'" Unsung, 28 August 2026. https://unsung.aresluna.org/they-had-no-concept-of-a-duty-of-care-to-their-users/. Accessed 2026-09-28. ↩

  14. bfredl (Neovim maintainer). Merge comment on "Save extmark undo information when writing to undofile" (by chentoast) — neovim/neovim pull request #13973, 3 March 2021. https://github.com/neovim/neovim/pull/13973#issuecomment-789544740. Accessed 2026-09-28. ↩ ↩2

  15. layer8. Comment on Hacker News item 49867067, 27 September 2026. https://news.ycombinator.com/item?id=49867678. Accessed 2026-09-28. ↩

  16. kelnos. Comment on Hacker News item 49867067, 27 September 2026. https://news.ycombinator.com/item?id=49871562. Accessed 2026-09-28. ↩

  17. xigoi. Comment on Hacker News item 49867067, 27 September 2026. https://news.ycombinator.com/item?id=49870712. Accessed 2026-09-28. ↩