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

.swp vs .swo: What's the Difference?

Both are Vim swap files holding your unsaved changes. The difference is order: .swp is the primary one, and .swo is the fallback Vim creates when a .swp for that file already exists.

Category
Safe to delete?
Opens with

Short answer

Vim writes a swap file to protect your unsaved edits. The normal name is the file plus .swp. If a .swp already exists — because another Vim session has the file open, or a previous session crashed and left one behind — Vim can't reuse that name, so it falls back to .swo, then .swn, and so on. So .swp is the first/primary swap file and .swo is the second one for the same file.

Why you're seeing a .swo

  • A stale .swp is still there from a crash or a kill — Vim won't overwrite it, so the new session grabs .swo.
  • You're editing the same file twice at once; the second Vim takes the next free extension.

Which one do I recover from?

Recover from whichever swap file holds the newest unsaved changes — usually the most recently modified one (check timestamps with ls -la). Run vim -r yourfile and Vim lists the swap files it can recover from. After you've saved the real file, delete the leftover .swp/.swo so the warning stops appearing.

Are they safe to delete?

Yes — once you've saved your work, both .swp and .swo are disposable. They only exist to recover unsaved edits; deleting them never touches the real file. The only risk is deleting one that still holds changes you never saved.

FAQ

What's the difference between .swp and .swo in Vim?

They're both swap files for the same edited file. .swp is the primary name Vim uses; .swo is the fallback it creates when a .swp already exists (e.g. after a crash or a second open session).

Why did Vim create a .swo instead of a .swp?

Because a .swp for that file was already present. Vim never overwrites an existing swap file, so it steps to the next extension: .swo, then .swn, and so on.

Which swap file should I recover from?

The one with the newest unsaved changes — usually the most recently modified. Run 'vim -r yourfile' and pick the swap file Vim lists with the latest timestamp.

Is it safe to delete .swp and .swo files?

Yes, after you've saved your work. They only hold recovery data; deleting them doesn't affect the real file. Don't delete one that still contains edits you never saved.

Other file types explained