My setup is to use vim (specifically MacVim in graphical mode) to edit source files and then I do (mercurial) repository diffs using vimdiff (in graphical mode again). Sometimes, when I do a diff, vim gives me the error:
Swap file "~/nn/src/imm/model/injector_node/.values_table.py.swp" already exists!
How do I fix this? Can I command vim to stop making swp files, or the vimdiff to ignore them, or write its swp files to a different place?
Yes, (maybe), and yes.
To turn off swap files:
set nobackup
set nowritebackup
set noswapfile
To change location of swap files (my preferred choice):
" Set the directory of the swap file
" The // indicates that the swap name should be globally unique
set directory=~/.vim/tmp//,/tmp
Here I set it up in a tmp
directory under .vim
. See :h 'directory'
to find out what each part of the option represents.
As for getting Vimdiff to ignore the swap files, I'm not quite sure. But the error is probably occurring because when you're checking the diffs with Mercurial, you have the same files already open in MacVim. If you just close the files before performing the diff, then you should be fine.