When I try to open a file from multiple vim instances, I get an error with several options:

Swap file "~/.vim/tmp/file.swp" already exists!

What is the difference between "Quit" and "Abort"?

My first guess was, when I'm trying to open multiple files and only one is being edited elsewhere, "quit" may skip that one and "abort" quit the program, but that is evidently incorrect -- both just abandon the whole attempt at editing and drop back to the terminal.

  • 2
    Does :help swap-exists-choices answer your question? – FDinoff May 12 '15 at 3:27
  • @FDinoff it helps, but I'm not quite clear on "Abort" still. "also abort further commands. This is useful when loading a script that edits several files" - Are the "further commands" supposed to be from a vim script? Is it really common enough for a vim script to open new buffers that this is a concern? – Kevin May 12 '15 at 3:44

Try this: run vim file1 in a terminal, then run vim -p file1 file2 in a different terminal. The second command will prompt you as above. If you answer Quit, you still get to edit file2. If you answer Abort you just quit Vim, thus "aborting any further commands".

  • So is there only a difference when opening in tabs or split windows (-p/-o/-O)? Just using vim file1 file2 exits entirely on both quit and abort when file1 is being edited; and when file2 is being edited, the prompt doesn't appear until hitting next, and in that case both quit and abort just drop back to file1. – Kevin May 12 '15 at 17:46
  • 1
    You don't understand. Opening files is essentially a sequence of commands. vim file1 file2 does two things: it sets the arguments (the thing you can access with argv()), and it loads the first file in the buffer. The second file is actually loaded only when you run :n (or similar). When Vim prompts you the arguments have already been set, so if you Quit at that point there is no "further" command left to run. Also, other things count as commands too, f.i. autocmds and commands set with vim -c. You should think all this in terms of commands, not in terms of affected files. – lcd047 May 12 '15 at 18:23

@FDinoff suggested checking the vim help. In case anyone wanted to see these more easily:

WHAT TO DO?                                     *swap-exists-choices*


  Swap file ".main.c.swp" already exists! ~



   file contains changes that you want to recover.

   Vim editing the same file.
   are taken back to the previously edited file.


   newer than the swap file.
   swap file does not appear to be running.

As far as I can tell abort is for when you use vim to check through multiple files, like so:

vim file1.txt file2.txt

If the first one is locked and you call quit, it will go on to file2.txt, whereas abort will break out of the application entirely.

Your Answer

