Undo file format version 3 in Vim 9.0 blocks cross-version undofile sharing
0 reputation · 24 Mar 2021, 13:58 UTC
0 reputation · 24 Mar 2021, 13:58 UTC
Ensure that a repeatable development environment can persist undo history across different Vim versions used by team members.
Vim 9.0 writes undo files using format version 3, which Vim 8.2 and earlier cannot read, leading to silent loss of undo history when the same undofile is accessed with an older binary.
It is unclear whether Vim should provide a backward-compatibility mode or a version-selector option that forces the legacy undo file format by default, or if users must manage this externally.
Should Vim introduce a configuration option to write undo files in the legacy format?
Can an automatic detection mechanism be added to select the appropriate undo format based on the Vim version that will later read the file?
What impact would forcing the legacy format have on undo features introduced in Vim 9.0?
Vim has no supported option to write the legacy undo format, and an automatic detection mechanism is not technically feasible. The undofile is a binary cache tied to the writing binary's capabilities, not a portable interchange format. The correct fix for a mixed-version team is environmental: keep undofiles per-user and per-host, and never share them across Vim versions.
Vim's persistent undo ('undofile') serializes the undo tree to a file (by default .<filename>.un~) whose header carries a format version number. Vim 9.0 writes format version 3; Vim 8.2 and earlier cannot parse it. Critically, an older Vim does not warn or convert — it silently discards the unreadable undo state, so history is lost without any visible error. Vim has bumped this format before (versions 1 and 2 existed previously), and each bump broke readability by older releases. This is established behavior, though you should confirm exact version numbers against :help undo-persistence in your installed binaries.
Upstream has consistently treated the undofile as a local cache whose format is chosen by the serialization code, not by user configuration. There is no 'undoformat'-style option, and no signal that one is planned. Treat any claim of a hidden compatibility toggle skeptically — verify in :help options before relying on it.
The writer cannot know which Vim version will read the file later. There is no handshake or negotiation possible at write time for a file that may be opened days later by a different binary on a different machine. The only workable "detection" is at the environment level: wrapper scripts or vimrc logic that disables persistent undo in directories shared by mixed-version users.
If such an option existed, any undo state depending on Vim 9.0-only structures could not be serialized in the older format. Undo history would be truncated or lossy on save, and features relying on the newer state would degrade silently — the same failure mode you are trying to avoid, just moved from load time to save time.
'undodir' at a per-user, per-host location (e.g. ~/.vim/undo or under $XDG_STATE_HOME) so undofiles never sit in shared or networked project trees..un~ files to version control — they are binary, host-specific, and version-fragile.:version
:help undo-persistence
:set undodir?
For a concrete test: enable 'undofile', edit and save a file in Vim 9.0, then open it in Vim 8.2 and check whether undo history survives. Inspecting the .un~ header bytes will show the format version field. Also search :help options in your newest installed Vim to confirm no undo-format setting has been added since this was written — this area is version-sensitive and worth a human check against your exact binaries.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.