Why does vim create
files? Is there a way to disable that?
If it\'s for backup (or something), I use git for that.
Also, thes
Put this in your .vimrc configuration file.
set nobackup
On Windows add following lines to _vimrc
" store backup, undo, and swap files in temp directory
set directory=$HOME/temp//
set backupdir=$HOME/temp//
set undodir=$HOME/temp//
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
I have this setup in my Ubuntu .vimrc. I don't see any swap files in my project files.
set undofile
set undolevels=1000 " How many undos
set undoreload=10000 " number of lines to save for undo
set backup " enable backups
set swapfile " enable swaps
set undodir=$HOME/.vim/tmp/undo " undo files
set backupdir=$HOME/.vim/tmp/backup " backups
set directory=$HOME/.vim/tmp/swap " swap files
" Make those folders automatically if they don't already exist.
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), "p")
endif
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), "p")
endif
This answer applies to using gVim on Windows 10. I cannot guarantee the same results for other operating systems.
Add:
set nobackup
set noswapfile
set noundofile
To your _vimrc file.
Note: This is the direct answer to the question (for Windows 10) and probably not the safest thing to do (read the other answers), but this is the fastest solution in my case.
; For Windows Users to back to temp directory
set backup
set backupdir=C:\WINDOWS\Temp
set backupskip=C:\WINDOWS\Temp\*
set directory=C:\WINDOWS\Temp
set writebackup