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.
maerics Jan 09 '14 at 17:03 2014-01-09 17:03
source share