Swap file .file.swp already exists![O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:I usually see this message when I accidentally :edit the wrong file, i.e., one which I'm already editing in another terminal. My preferred solution in this case would be to tell Vim: oops, that was a mistake, please do nothing.Both [Q]uit and [A]bort work, but they also add the file to the buffer list. I usually have a number of buffers open and page through them with the F3 and F4 keys, which I have mapped to :up plus :bp and :bn, respectively. This means I have to manually :bd the accidentally added file.This happens often enough that it's becoming annoying, and for some reason I don't seem to be learning from repeating this particular mistake. Is there a way to avoid adding the file to the buffer list? If not, what would be a good way to automate delete the last opened buffer?Related:What's the difference between quit and abort?
Swap choices: how can I skip instead of quit or abort?
buffers;swap file;quit
I agree with you, and this seems like it could be improved, because one of those you would think would not create the buffer, and I just verified that I see the same behavior you describe, but if I were in your shoes what I would do to guarantee the buffer is immediately destroyed and which comes close to automatic is [O]pen Read-Only followed immediately by a :bw instead of :bd. That's 3 additional keystrokes. One minor note, your question assumes you have a running session with other buffers that you want to keep, and this :bw command will not quit that session in any context.(I would note that the frequency of the Swap file exists message in general is a pet peeve of mine with GVim, even though I really adore GVim and Vim and even though I am aware of workarounds via remote_foreground, single sessions, and such. But I believe GVim should bring me to the editor that is already open, assuming it's another GVim instance. Bringing to front an existing GUI window already open on a certain file is a feature of GUI editors since the time immemorial.)