:h shortmess says:

A    don't give the "ATTENTION" message when an existing swap file is found.

But then what does Vim do about the existing swap file? Some people say it's bad to use that option, why so?


If you set A option Vim will just forget about swap at all.

You'll stop getting messages about a swap file being found and if you're editing the same file in different terminals at the same time, it's your problem <3


What I mean is that Vim will not care about the swap file

Let's put a example:

You open main.c in terminal A, and you write something in it. You save it with :w without closing vim.

Then you open main.c in terminal B and edit it again, You save it with wq. (normally at this point the swap attention text would appear, but you have disabled it)

Finally, in Terminal A, you edit it and save it with wq, exiting vim now. Then a prompt will appear telling you that the file has been changed since you opened it, and if you really want to save it or no.

If you say to save it anyway, result is that you'll lose all the stuff you wrote in the file in Terminal B, because Terminal A never "saw" it.

  • With set noswapfile Vim "will just forget about swap files at all". With shortmess+=A swapfiles are still created and modified, and I want to know how Vim handles conflicts if it doesn't ask you what to do, and why that would be a bad idea as long as you know what it's doing.
    – dbmrq
    Jun 5 '17 at 23:16
  • I tried to explain it better, check the updated answer
    – criw
    Jun 5 '17 at 23:24

According to :help swap-file:

  • If this file already exists (e.g., when you are recovering from a crash) a warning is given and another extension is used, ".swo", ".swn", etc.
  • An existing file will never be overwritten.
  • The swap file is deleted as soon as Vim stops editing the file.

So if you realise that you need to recover from a swap file, even without the warning, then you can still manually recover it at any time unless you explicitly deleted it.

I've decided to use the shortmess=A option because:

  • Nearly all of the swap file warnings are false positives (e.g. my PC crashed, but the file was already saved because I have set Vim to auto save when the window focus changes).
  • If there is ever a genuine loss of data, then I will probably notice the problem without the warning, and be able to manually recover the data from the swap file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.