undofile persistence boundary with writebackup on read-only buffers
0 reputation · 09 Mar 2026, 03:34 UTC
Persistent undo via 'undofile' and 'undodir' is a documented Vim feature for retaining undo history across sessions independent of swap-based crash recovery.
The documented boundary between undo persistence and file write semantics is relevant when a buffer is read-only and 'writebackup' is configured. The interaction of 'undofile' with write access checks, and the conditions under which an undo file is created, updated or pruned for read-only files, is an unresolved decision point in configuration guidance.
Clarifying this behavior matters for setups that separate undo storage from working directories and apply least-privilege permissions to the 'undodir' because undo files can retain sensitive edit data.
Does Vim update the undo file for a read-only buffer when 'undofile' is enabled and 'writebackup' is set? Under what documented conditions is an undo file created or pruned for read-only files? How does the documented behavior differ between Vim 7.4+ persistent undo and later versions regarding write access checks?