I work with many terminals, and very often hit the case where:

  • a vim instance holds ~/sm/file
  • I open another instance on the same file.

My choice is always :(E)dit without prompting ... So I'd like vi to "remember my choice" for every file.

Many posts explain how to ignore swap files. * That is not what I want :) *

The typical, well known message is:

Found a swap file by the name "~/sm/.file.swp"
          owned by: FRY02339   dated: Tue Oct 29 10:41:13 2019
         file name: ~FRY02339/sm/file
          modified: no
         user name: FRY02339    host name: shinwey
        process ID: 60165 (still running)
While opening file "/home/FRY02339/sm/file"
             dated: Tue Oct 29 10:41:09 2019

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r /home/FRY02339/sm/file"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/home/FRY02339/sm/.file.swp"
    to avoid this message.

Swap file "~/sm/.file.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

Do you have any hint ?

  • 2
    Mildly good news in Vim 8.2 for those who don't bother setting up a default choice: an existing swap file identical to the just opened one will be deleted automatically.
    – B Layer
    Commented Apr 21, 2020 at 15:18

1 Answer 1


Through the SwapExists event, you can influence the choice (and skip the dialog) by setting the special v:swapchoice variable:

autocmd SwapExists * let v:swapchoice = "e"

(I personally would at least add an | echomsg "Concurrent editing" to notify that there's concurrent editing going on.)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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