Why is it when I create/save my file (say, filename is 'xyz.sql'), gvim saves another file which it calls 'xyz.sql~' in the same directory? Can I delete this "extra" files or are they needed for some reason? Even when I close gvim, they are still present.
2 Answers
You have set the 'backup' option, so Vim creates a backup file when saving
the original file. You can stop Vim from creating the backup file, by
clearing the option:
:set nobackup
As another answer correctly says, these are backup files. I wanted to just add that if you want to still have backup files, but don't want them to clutter your directories, you can use the backupdir
option:
set backupdir=~/.backups,.
From the vim help:
List of directories for the backup file, separated with commas.
- The backup file will be created in the first directory in the list where this is possible. The directory must exist, Vim will not create it for you.
- Empty means that no backup file will be created ('patchmode' is impossible!). Writing may fail because of this.