Vim swap file retention after a failed upgrade
0 reputation · 21 Nov 2025, 07:40 UTC
Swap file behavior after an upgrade crash
Vim creates a temporary swap file (.swp) for each buffer to enable crash recovery. Normally the file is removed when the buffer is closed cleanly. When a Vim upgrade process fails—e.g., due to an interrupted package install or a forced shutdown—the editor may terminate without executing its normal cleanup logic. The resulting stale swap file can cause the next Vim launch to either prompt for recovery or refuse to open the file, depending on the file’s state and the user's configuration.
Key uncertainty: Does Vim automatically delete a swap file that remains after a crash, or is manual intervention required? How does the presence of such a stale swap file affect concurrent editing attempts or the behavior of the :checktime command? Are there documented policies governing this cleanup across Vim 8, 9, and Neovim?
Questions:
- When Vim exits unexpectedly, does it leave the swap file in place or delete it automatically?
- What conditions trigger Vim to remove a stale swap file during a subsequent launch?
- How should a user reliably recover or discard a swap file left by a failed upgrade?