.SWP

SWP File

Vim Swap File
Ask a question
QUICK ANSWER

A .swp file is a temporary recovery file Vim creates automatically when you open a file for editing. It stores unsaved changes so they can be recovered after a crash. Do not open the .swp file directly - open the original file in Vim instead and choose Recover or Delete when prompted.

Developer: Bram Moolenaar (Vim); originally vi by Bill Joy (1976) Category: Misc Files MIME: application/octet-stream
OPENS ON Windows macOS Linux
Related: .TORRENT · .MSO · .MD5 · .SHS

On this page

19k+ extensions indexed
Last reviewed Jun 14, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the SWP file format?

.swp is a Vim swap file - a temporary binary file that Vim creates automatically when you open a file for editing. Its purpose is crash recovery: if Vim exits unexpectedly due to a power loss, terminal close, or system crash, the swap file preserves unsaved changes that can be recovered on the next launch.

Vim creates the swap file in the same directory as the edited file, naming it with a leading dot and .swp suffix - for example, editing config.py produces .config.py.swp. On Unix-like systems the leading dot makes it hidden by default. If multiple Vim sessions edit the same file, subsequent swap files use .swo, .swn, and so on.

The swap file has a binary block-based structure. The first 4 KB block (block 0) contains a b0VIM magic header, the Vim version string, the original file path, hostname, username, and process ID. Subsequent blocks store the buffer contents organized as a B-tree of 1 KB pages. File contents are stored in plaintext - the swap file is not encrypted.

When Vim opens a file and detects an existing .swp, it prompts you to Recover (r) the unsaved changes or Delete (d) the stale file. A leftover .swp with no running Vim process is safe to delete; run vim -r filename to attempt recovery explicitly. Neovim uses the same swap format.

One security consideration: .swp files left in web server directories can expose unencrypted source code if the server is configured to serve hidden files.

Security & safety

RISK: MEDIUM

The .swp file itself is not malware, but it poses an information-disclosure risk: (1) Left in a web-accessible directory, it exposes the full plaintext of the file being edited plus server hostname and username - a classic recon finding in pentests. (2) Accidentally committed to git: 'git rm --cached .*.swp' and add '*.swp' to .gitignore. Add '*.swp' to your global .gitignore (~/.config/git/ignore) to prevent accidental commits.

Format details

in a nutshell
FULL NAMEVim Swap Fileaka Vim swap, vi swap file
DEVELOPERBram Moolenaar (Vim); originally vi by Bill Joy (1976)since 1991 (Vim 1.0); vi swap concept from 1970s ex/vi
CATEGORYMisc Files
MIME TYPEapplication/octet-stream
TYPEbinary temporary/recovery file
This extension is also used by…
  • Windows Virtual Memory Swap File - Windows uses pagefile.sys/swapfile.sys, not .swp extension; confusion with OS swap is unfounded but common.
  • Oracle Forms .swp - Older Oracle Forms versions used .swp for a different swap buffer; very rare.
MAGIC BYTES · FILE SIGNATURE
OFFSET
000102030405
HEX
623056494D20
ASCII
b0VIM
Swap files by nano start with 'b0nano'; Vim swap is identified by 'b0VIM ' prefix. The header at block 0 also stores Vim version string, filename, hostname, and username.

Programs that open SWP files

Windows2 apps
gVim Open-source Open the original file in gVim; the swap dialog appears. Choose 'Recover' to restore unsaved edits.
Neovim for Windows Open-source Same recovery workflow as Unix Vim.
macOS2 apps
MacVim Open-source Open original file in MacVim; it detects the swap and offers Recover/Delete.
Vim (Terminal) Open-source Use 'vim -r' in Terminal to list and recover from swap files.
Linux3 apps
Vim Open-source Open the ORIGINAL file (not the .swp) in Vim; choose 'R' to recover or 'D' to discard the swap.
Neovim Open-source Same as Vim: open the original file; Neovim reads Vim-compatible swap files.
vim -r (recovery mode) Open-source Run 'vim -r filename' or 'vim -r' (lists all swap files) to recover unsaved changes.

Technical details

deep spec
File purposeCrash-recovery buffer for active Vim editing sessions; automatically deleted on clean exit
Magic bytes`62 30 56 49 4D 20` ("b0VIM ") at offset 0
Block structureBlock 0: 4 KB header; subsequent blocks: 1 KB pages in a B-tree; total size grows with buffer contents
Header contentsVim version string, original file path, hostname, username, and PID stored in block 0
Content encodingPlaintext (no encryption); original file content is directly readable from the swap file
Byte orderPlatform-dependent (matches host Vim build; typically little-endian on x86 and ARM)
Naming convention`.filename.swp` (leading dot + `.swp` suffix); hidden on Unix systems by default
Overflow namingWhen multiple sessions edit the same file: `.swo`, `.swn`, `.swm`, … allocated alphabetically
Stale detectionVim cross-checks PID and hostname in block 0 header; warns if the recorded process is no longer running
Recovery command`vim -r filename` or press `r` at the recovery prompt when reopening the file in Vim
Neovim compatibilityNeovim reads and writes Vim-compatible swap files using the same `b0VIM` header format
Security noteSwap files in web-accessible directories expose source code as plaintext if the server serves dotfiles
Released1991 (Vim 1.0); vi swap concept from 1970s ex/vi
Latest versionVim 9.1 (2024) swap format; compatible block-based format since Vim 6
Specificationgithub.com

SWP conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with SWP files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about SWP files.

Frequently asked questions

How do I get rid of .swp files?
If Vim exited cleanly they should not exist. Delete a stale .swp manually (rm .filename.swp), or open the original file in Vim and choose 'D' (delete swap). Add *.swp to .gitignore to keep them out of version control.
Can I open the .swp file directly to recover my text?
No - .swp is binary. Use 'vim -r yourfile.txt' (or just open yourfile.txt in Vim) to recover; Vim reconstructs the text automatically.
Why does Vim say the file is already in use?
Another Vim session has the swap open, or Vim crashed. Check for other Vim processes (ps aux | grep vim). If none exist, delete the stale .swp and reopen.
I found a .swp file on a web server - is this a security issue?
Yes. It leaks the full source of the file being edited plus system metadata (hostname, username). Remove it and add *.swp to your web server's deny rules.
Where does Vim store swap files?
By default, in the same directory as the file being edited. You can redirect them with 'set directory=~/.vim/swapfiles//' in .vimrc to keep them out of project directories.

References

1Vim documentation - Swap files (:help swap-file)vimhelp.org
2Vim source - memline.c (swap format implementation)github.com

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.PARTPartial Download File
4.BINCD/DVD Disc Image (BIN/CUE)
5.RPMSGRestricted Permission Message
6.MDMarkdown Document
7.NOMEDIAAndroid No-Media Marker File
8.PRO6XProPresenter 6 Bundle File
9.PRDXSoftMaker Presentations Document
10.EXEWindows Executable (Portable Executable)

Related extensions

.TORRENTBitTorrent Metainfo File
.MSOMicrosoft Office HTML/OLE Data Stream (oledata.mso)
.MD5MD5 Checksum File
.SHSShell Scrap Object File
.DDDAdobe Acrobat Distiller file
.DWLDrawing Lock File (CAD)

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z