tags:

views:

440

answers:

4

I use gvim on windows and I want to know a way to disable the temp file(ending in ~) file creation. Also is there a problem if we do it ?

+6  A: 

You can disable the backup file by putting this line in your .vimrc:

set nobackup

I almost always do this, as the ~ file is more annoying that useful. There is no problem with doing this, you'll just lose the ability to revert to a backup of the file.

If you want to get rid of the temporary .swp (swap) file too, you can also set this:

set noswapfile

The swap file is created when you have a file open, and provides some backup/recovery security, in case Vim crashes while editing a file. It also can prevent multiple Vims from editing the same file. I usually just turn this off too, because I rarely have a use for it. The .swp file isn't as annoying as the ~ file, because it goes away when you close Vim, but I still just turn that feature off.

Andy White
Excepting the fact that you have no chance of recovery in case of vim crashing, or (much more likely, depending on your environment) a severed terminal.
Richo
Yeah, you do lose the backup capability, but I've almost never had a problem with Vim crashing or losing a connection, so I roll the dice.
Andy White
+1  A: 

put these in your vimrc file

set nobackup
set nowritebackup
set noswapfile
ghostdog74
+1  A: 

From inside vim:

:e $HOME/_vimrc

and add this to the file:

set nobackup

Then, $HOME/_vimrc~ will hopefully be the last backup that vim makes!

Alok
+1  A: 

It's not quite what you asked for, but something that I've found works well is to redirect the swap and backup files to a seperate, dedicated folder. That way, they're still there if I need them, but they're not cluttering up the folder I'm working in.

Here are the lines from my _vimrc file:

"Put vim files in the temp directory instead of the current directory
set dir=c:\\temp
set backupdir=c:\\temp

Warren Pena