Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GVIM on windows: way to disable the tmp file creation

Tags:

vim

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?

like image 789
gameover Avatar asked Feb 04 '10 06:02

gameover


People also ask

What is Vim backup?

Vim helps protect you from unintentionally losing data by letting you make a backup of the files you edit. For an edit session that has gone terribly wrong, this can be useful because you can recover your previous file. Backups are controlled by the settings of two options: backup and writebackup .

Where is the Vimrc file on Windows?

vim/ directory ($HOME/vimfiles/ for MS-Windows). That makes it easy to copy it to another system.

Where are Vim swap files stored?

While editing a file, you can see which swap file is being used by entering :sw . The location of this file is set with directory option. The default value is .,~/tmp,/var/tmp,/tmp . This means Vim will try to save this file in the order of . , and then ~/tmp , and then /var/tmp , and finally /tmp .


2 Answers

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.

like image 84
Andy White Avatar answered Sep 30 '22 10:09

Andy White


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.

The _vimrc file can be created in any of the following locations:

  • %HOMEPATH%\_vimrc
  • C:\Program Files (x86)\Vim\_vimrc

The following lines in the _vimrc file put backup files into a temporary directory:

set backup set dir=%TMP% set backupdir=%TMP% set directory=%TMP% set noundofile 

The last line prevents the proliferation of undo files.

like image 28
Warren Pena Avatar answered Sep 30 '22 10:09

Warren Pena