29

If I restart vim after a crash, it'll tell me that a swap file for my file exists, and ask me what to do--open anyway, recover the file, quit, abort, etc. Sometimes it gives me the option to delete the swap file, and that's usually the option I need. Other times, however, it doesn't give me that option for some reason. Why is that, and how can I get vim to allow me to delete swap files from within vim? (Because deleting it manually is a pain.)

1

1 Answer 1

28

From :help swap-exists:

D  Delete the swap file.  Use this when you are sure you no longer need it.
   For example, when it doesn't contain changes, or when the file itself is
   newer than the swap file.
      On Unix this choice is only offered when the process that created the
   swap file does not appear to be running.

So it sounds like Vim somehow believes another Vim process is still actively running on that file.

2
  • 4
    Oh cool. I see now that when my SSH connection was lost, the vim process was still there in the background somehow.
    – Jonathan
    Apr 30, 2014 at 14:17
  • 1
    +1 for the :help swap-exists. I was always confused about the options.
    – wisbucky
    Nov 20, 2019 at 2:44

You must log in to answer this question.

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