Code for Concinnity

beautiful and elegant solutions


gvim — E303: Unable to open swap file for “[No Name]“, recovery impossible

vim is my editor of choice and I install it in Windows. All is working quite good except one little annoyance — when I open the editor fresh and started editing by going into insert mode, it will give this error message:

1
E303: Unable to open swap file for "[No Name]", recovery impossible

This is usually harmless, as soon as I save the file everything would be great, it’s just that 1 – 2 seconds of pause that doesn’t make me feel good, so today I tried to pin down the problem and here’s how it went:

1
2
3
4
5
6
7
:help E303
(So it's related to the swap file. Let's see where our swap file fails to be created.)
:set directory?
directory=.;c:\tmp;c:\temp
(Oh, those are the default %TEMP% which I moved to another drive! But anyway, the first priority should be the current directory. So let's see where we're now)
:pwd
C:\Windows\system32

Solution

OK it’s pretty obvious now. It probably needs a little bit of manual fixing. Let’s put this in our .vimrc

1
2
3
4
5
" Thanks for an anonymous guest to provide this generic, better solution
set directory=.,$TEMP

" This is line I used at first. The above line is better than this

set directory=.,d:\temp

Great, problem solved!

Published by kizzx2, on November 6th, 2009 at 3:58 am. Filled under: Useful tips Tags: , , , 6 Comments

6 Responses to “gvim — E303: Unable to open swap file for “[No Name]“, recovery impossible”

  1. just a remark, it should be set directory=.,whatever

    not ;

    Comment by Juan on December 10, 2009 at 6:40 pm



  2. @Juan: Thanks! Fixed.

    Comment by kizzx2 on December 10, 2009 at 6:44 pm



  3. Or more generically:

    set directory=.,$TEMP ” default dir for swap files

    Comment by guest on January 21, 2010 at 2:04 am



  4. Awesome! Thanks – that did the trick.

    Comment by Charles Strahan on February 17, 2010 at 8:27 am



  5. Thanks. Worked wonderfully.

    Comment by Josimar on February 21, 2010 at 9:26 am



  6. Brilliant! This was making me angry (at least it was making me use VIM less). Thanks!

    Comment by Timothy Chen Allen on June 27, 2010 at 10:33 am



Leave a Reply

Spam protection by WP Captcha-Free