Home > howto > Change Vim Swap (.swp) files default path

Change Vim Swap (.swp) files default path

I work with subversion as a version controller, and I’m a big fan of console. But it’s quite annoying to type a “svn status” and receive lots of question marks on something.swp or .sw0 . Other version control system probably suffer from this issue, unless they have recursive ignore (which, as far as I can tell, svn doesn’t)

Well, I just found Vim Tip #20, which teaches us how to change the folder path for swp files. This way, all swap files for Vim (and, of course, gVim) will be saved on the specified directory.

The comand is :

set directory=/path/to/dir,/path/to/another/dir

There is also “set backupdir=/path/to/dir” to move those something.rb~

Hope this helps you as much as it helped me!

Categories: howto Tags:
  1. Ben Collins-Sussman
    November 19th, 2007 at 00:39 | #1

    Or, you could just set your “global-ignores” variable in ~/.subversion/config file to include “*.swp”. Then subversion would never complain about .swp files ever again. :-)

  2. November 19th, 2007 at 02:32 | #2

    Wow, Ben, that’s new for me! Thanks, I’ll take a look! :)

    Just a question: You wouldn’t be “the” Ben Collins-Sussman, creator of Subversion, would you?

  3. Jaisen
    March 7th, 2008 at 19:55 | #3

    Nice…for some reason set nobackup wasn’t working. I don’t even remember where I saw that. This worked great.

  4. June 30th, 2008 at 09:40 | #4

    Well, even if you ignore *.swp files the windows-command line could be anoying if you would like to add some files to your repository (I’m useing mercurial and so I have some .hgignore file). So thanks for the hint!

  1. No trackbacks yet.