Vim – don’t save backups if in svn working copy

vim

I like that vim automatically saves backup files, but it is annoying when I use vim to edit a file that is in a svn working copy, since the files are already "backed up", and it creates clutter.

How do I configure vim to only save backups when I am editing a file that is NOT in a svn working copy?

Best Answer

Not an answer to your specific question, but I believe a better solution. Why not backup all your files into a separate directory, regardless of whether they are in source control?

Here's how, from my .vimrc. This creates the backups in the common ~/.vim_backups directory:

" Use a common directory for backups and swp files
" Create it if it doesn't exist
silent execute '!mkdir -p ~/.vim_backups'
set backupdir=~/.vim_backups//
set directory=~/.vim_backups//