How to change the folder path for swp files in Vim

I am working on a project on a remote server. I do not want to have swap files on the server. I would like all swap files for Vim (and, of course, gVim) to be stored in the specified directory. How could I do this?

+46
vim
Oct 28 '09 at 10:11
source share
2 answers

You can set the directory option in the place where you want vim to save its swap files, for example:

 " $HOME/.vimrc :set directory=$HOME/.vim/swapfiles// 

I use double-path trailing delimiters because from the docs help:

For Unix and Win32, if the directory ends with two path separators "//" or "\\", the paging file name will be created from the full path to the file with all path separators replaced by percent signs. This ensures that the file name in the save directory is unique.

+48
Jan 09 '14 at 17:03
source share
— -

You might also want to set backupdir options:

 set backupdir=Z:\backups 

This makes backups of the vim repository in a specific place, and not in the current directory.

+22
Oct 28 '09 at 12:28
source share



All Articles