Why doesn’t vim always give me the option to delete a swap file


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.)

Best Answer

  • 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.

  • Related Question