views:

2345

answers:

3

Why does vim create <filename>~ files? Is there a way to disable that?

If it's for backup (or something), thanks but no thanks, I use git so I don't need your silly backup.

Also, these .<filename.with.path.hints>.swp files too.

How do I tell vim not to create those? or at the least to cleanup after itself?

EDIT

wops, duplicate:

http://stackoverflow.com/questions/607435/why-does-vim-save-files-with-a-extension

I adopted rogeriopvl's answer from there

verbatim copy:

set nobackup       #no backup files
set nowritebackup  #only in case you don't want a backup file while editing
set noswapfile     #no swap files
+8  A: 
:set nobackup

In your .vimrc file.

Chad Birch
+7  A: 

This doesn't look like it was covered in the duplicate. Sooner or later, a temporary backup will save your skin, even with source control, so try this:

set backupdir=~/tmp
Andy
don't forget to make the dir first
rampion
I absolutely agree, it has saved my skin a few times.
Ray Hidayat
To make your vimrc more portable, you can set multiple backupdirs. Vim will use the first one that's an actual directory. For example,set backupdir=~/.vim-tmp,~/tmp,/var/tmp,$HOME/Local\ Settings/TempThat last one will even work on Win32.
thomasrutter
+4  A: 

I'd strongly recommend to keep working with swap files (in case Vim crashes).

You can set the directory where the swap files are stored, so they don't clutter your normal directories:

set swapfile
set dir=~/tmp

See also

:help swap-file
well, I never needed those with notepad++, unless you say that vim will crash too often!
hasen j
no, I wasn't implying that vim crashes too often (though I've seen it crash). But for my working environment, the network connection to some host I'm working on is quite unstable, so interrupted editing occurs. Swap files help there.