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

What Is a .SWN File?

A .swn file turned up beside your document. It is Vim's third swap file — a sign the same file was opened several times. Here is how to handle it.

Category
Safe to delete?
Opens with

What a .swn file is

A .swn file is a Vim swap file — a crash-recovery copy of your unsaved edits, exactly like a .swp. The n at the end tells you it is the third swap file Vim had to create for the same document. Vim tries .swp first, then .swo, then .swn, walking backwards through the alphabet each time the previous name is already in use.

Why a third swap file appears

Seeing a .swn means the same file already had a .swp and a .swo when Vim opened it again. That usually happens when a document is open in two or three Vim sessions at once, or when earlier sessions crashed and their swap files were never removed. It is Vim protecting every copy of your unsaved work.

How to recover from a .swn

Open the original file and pick (R)ecover at Vim's prompt, or run vim -r yourfile. Vim locates the swap file automatically and restores the unsaved changes so you can save them. Because several swap files may exist, review the recovered text carefully and keep the newest good version.

Is it safe to delete a .swn file?

Yes, once you have recovered what you need. The .swn is only a recovery copy; deleting it never touches your real document. On Linux or macOS the file is hidden — list it with ls -a and remove it with rm .yourfile.swn. It is good practice to delete leftover .swp, .swo and .swn files together so Vim stops warning you.

Stopping the pile-up

If swap files keep stacking up, close the extra Vim sessions holding the file, or set a dedicated swap directory with set directory=~/.vim/swap// in your .vimrc so they no longer clutter your working folder.

FAQ

What does a .swn file mean?

It is Vim's third swap file for one document — created because a .swp and a .swo already existed, usually from the file being open in several sessions.

How do I recover from a .swn file?

Open the file in Vim and choose (R)ecover, or run vim -r yourfile, then save the restored text.

Is it safe to delete a .swn file?

Yes, after recovering any unsaved changes. It is only a recovery copy, not your document.

Why do I have .swp, .swo and .swn all at once?

The same file was opened multiple times (or earlier sessions crashed). Vim adds a new swap file each time the previous name is taken.

Other file types explained