Swap file error message while trying to edit .vimrc file?
Everytime I try to open the .vimrc
file I am getting this message .I am using the vimtutor
in another terminal but I don't think I have opened up any extra .vimrc
file . Why do I see this error and how can I fix this ?
E325: ATTENTION
Found a swap file by the name ".vimrc.swp"
owned by: subhrcho dated: Wed Dec 26 05:54:45 2012
file name: ~subhrcho/.vimrc
modified: YES
user name: subhrcho host name: slc04lyo
process ID: 26176
While opening file ".vimrc"
dated: Mon Jan 28 22:45:16 2013
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 .vimrc"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".vimrc.swp"
to avoid this message.
Swap file ".vimrc.swp" already exists!
The swap file is a month old (Dec 26), so it's probably save to delete it. On that day, you probably killed a Vim instance (or it crashed), leaving behind the swap file. Vim will never clean these up itself, you have to delete it yourself (or choose the delete option when Vim asks you).
BTW, the recover.vim - Show differences for recovered files plugin greatly enhances the swap file experience, e.g. by offering to show a diff of the changes.
vi
uses a swap file to keep a copy of your edits until you either save or discard them.
You see this error because either:
You are editing
.vimrc
twice (improbable, since you are only usingvimtutor
).vi
was killed while.vimrc
was being edited.
In the latter case, vi
couldn't clean up the swap file .vimrc.swp
, so it nicely asks you whether you want to recover the changes or discard them:
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r .vimrc"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".vimrc.swp"
to avoid this message.
If you haven't made any changes to .vimrc
(for example, you used vi
to open the file -- in the future use less
instead), simply delete the file:
$ rm .vimrc.swp
If you have made changes to the file, open it with vi
and press R. You may get error E309:
E309: Unable to read block 1 from .vimrc.swp
In this case delete the swap file as explained above. If you could open the file, type:
:recover
Review the file and save it with:
:x
Then delete the swap file to get rid of the message.