How to turn off automatic saving of a vim file with a ~ suffix

vim

In my environment, I share vim configuration with other developers (and have my own configuration additions as well) in various .vimrc files. Some places in the environment, I edit a file in vim and automagically a copy of that file with a trailing tilde suffix appears. What vim options control this? I'd like to turn the feature off, as it just clutters up my directories and spoils auto-completion on the command line.

Thanks.

Best Answer

If you just want to turn off backups entirely, the :set nobackup suggestion from @GregHewgill is the way to go.

However, I've been saved by Vim's backups often enough that I'd like to recommend an alternative. I have these settings in my .vimrc:

set backupdir-=.
set backupdir^=~/tmp,/tmp

The first line removes the current directory from the backup directory list (to keep the ~ backups out of your working directories). The second tells Vim to attempt to save backups to ~/tmp, or to /tmp if that's not possible. (The paths can be adjusted for your particular environment; I use set backupdir^=$TEMP on Windows, for example.)

In other words, this puts the backup files out of sight (and out of your way), but doesn't turn them off entirely.