Friday, April 16, 2010

cluttered gviw backup files

Below info is from   http://my.opera.com/peterchenadded/blog/2008/12/27/gvim-7-1-swap-and-backup-files, which puzzled me few years.

A swap file is a file that contains changes made to the original file. it matches *.swp.
A backup file is created right after saving changes to a newly opened file. it is a copy of the file before changing the file. it matches *~ where the * is the original filename.
So logically, by definition you can put them together to make the original or original plus some or all changes made.
source: http://www.ph.unimelb.edu.au/~ssk/vim/recover.html

Normally, both files appear in the directory of the file being edited. This can make the directory very cluttered, so would be better to remove it some where else. To do this use

set directory=c:/vim_swap_files
set backupdir=c:/vim_swap_files


You will need to create the vim_swap_files folder before it will work.
Add the lines to the c:\program files\vim\_vimrc file or in vim edit -> startup settings and add the lines and you will never have to worry about it again.