Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If vim crashes and leaves me with a .swp file that is empty (i.e., file size = 0), does that mean I didn't make any changes to the file during the session in which my computer crashed?

If so, then is there a way to change the settings so that vim will prompt me about “swap” files only if they are non-empty?

share|improve this question

It can mean there were no unwritten changes, or it could mean Vim did not have a chance to save to the swap file; Vim doesn't write the swap file constantly. See ":help 'updatetime'" (with the single quotes as part of the command).

In light of this, having Vim prompt you even with an empty swapfile can be a useful warning that something went wrong, and to take a close look at your file for lost data.

share|improve this answer

Vim swap files begin with the magic string b0VIM followed by a space and the Vim version number. An empty swap file is not normal and may indicate a more serious problem.

Note that the ATTENTION message exists partly to warn you when another Vim process is editing the same file, so you may want to keep it even for cases where you know there are no pending changes. The warning tells you whether the file is modified and whether the previous process is still running: If neither, it should be safe to delete the swap file, otherwise you should proceed with caution.

You can disable the ATTENTION message with set shortmess+=A, but Vim does not expose enough information about recovery in the API to disable the message automatically in low-risk situations. If you're very careful about workflow, you could disable the message and then deal with recovery manually as necessary. If you take this approach, you may want to streamline swap file processing like this:

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .