Or: how do I not generate the .swp files at all?

E325: ATTENTION
Found a swap file by the name ".notes.swp"
          owned by: james   dated: Fri Dec  3 17:38:07 2010
         file name: ~james/school/se/project-dir/rottencucumber/doc/notes
          modified: no
         user name: james   host name: james-laptop
        process ID: 2251 (still running)
While opening file "notes"
             dated: Fri Dec  3 18:46:10 2010
      NEWER than swap file!

(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 notes"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".notes.swp"
    to avoid this message.

Swap file ".notes.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:
link|improve this question

76% accept rate
feedback

2 Answers

up vote 5 down vote accepted

The pasted message suggests you still have the "notes" file open in another Vim session. It is definitely not a good idea to edit a file that is being edited elsewhere.

If that message is wrong, you need to determine how your Vim session exited improperly and avoid that in the future.

As for recovering, that may be an issue in this one instance since "notes" is newer than the Vim .swp file associated with it, but you can still try. Just make sure you copy your "notes" file to a backup location first.

It would be a good idea to read through ":help recover.txt".

The lesson here is that you're not supposed to be seeing this message, and that you are means Something Went Wrong Somewhere. It's (probably) not the fault of Vim.

If at this point you are still absolutely determined not to let Vim create .swp files so you can recover from crashes and other related issues, you may put "set noswapfile" in ~/.vimrc.

link|improve this answer
feedback

vim will remove the generated .swp file when you exit it properly.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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