whatfileis.pro
Paste a filename and find out what it is, whether it is safe, and what opens it.

Found a Swap File by the Name — What to Do

If Vim shows 'E325: ATTENTION — Found a swap file by the name ".file.swp"', it found a leftover .swp from a crash or a second open session. Pick (R)ecover first to get any unsaved work, compare it, then delete the swap. Below is what every option does and how to decide.

Category
Safe to delete?
Opens with

Which option to pick

At the prompt Vim offers single-key choices. In almost every case the safe order is (R)ecover → inspect → delete the swap:

  • (O)pen Read-Only — view the file without editing. Safe, but won't give you unsaved changes.
  • (E)dit anyway — edit the original ignoring the swap. Risky if another Vim still has the file open.
  • (R)ecover — rebuild the buffer from the swap. Start here to get unsaved edits back.
  • (D)elete it — remove the swap. Only after you've recovered what you need, or if you're sure it holds nothing.
  • (Q)uit / (A)bort — back out and change nothing.

The safe recovery sequence

  1. Press r to recover. Vim loads the swap contents into the buffer.
  2. Save to a new name so you don't clobber the original: :saveas yourfile.recovered.
  3. Compare both versions: :diffsplit yourfile.txt shows exactly what the swap added.
  4. When happy, keep the version you want and delete the swap: quit Vim, then rm .yourfile.txt.swp (it's hidden — list with ls -a).

Why it appeared

Vim writes a .swp while you edit and normally removes it on clean exit. A leftover means Vim (or the machine) crashed, or the file is still open in another session. If the prompt says 'process ID still running', a second Vim really does have it open — close that one instead of recovering.

FAQ

Found a swap file by the name — should I recover or delete?

Recover first. Press (R) to load any unsaved edits, save them to a new name, compare with the original using :diffsplit, and only then delete the swap. Delete straight away only if you're certain the swap holds nothing you need.

What do the (O)(R)(E)(D)(Q)(A) options mean?

(O)pen Read-Only views safely; (E)dit anyway ignores the swap; (R)ecover rebuilds unsaved changes from the swap; (D)elete removes the swap; (Q)uit and (A)bort back out without changes. Use (R) first, then (D) once you've saved what you wanted.

The swap file keeps appearing every time I open the file. Why?

The stale swap was never deleted, so Vim warns again each time. Recover or confirm you don't need it, then delete it: quit Vim and run rm .yourfile.swp (it's a hidden dotfile beside the original).

Other file types explained