tags:

views:

1375

answers:

5

Hi,

Is there a way to disable .swp files creation in vim? or at least create them all in one place so I can find and delete them easily. I find them especially annoying when I copy the parent directory while editing at the same time. Of course I know that I can use find -exec to find and delete them. But I want a more practical solution.

Thanks

+1  A: 

If you put set directory="" in your exrc file, you will turn off the swap file. However, doing so will disable recovery.

More info here.

Brian Rasmussen
+6  A: 

here are my personal ~/.vimrc backup settings

" backup to ~/.tmp 
set backup 
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp 
set backupskip=/tmp/*,/private/tmp/* 
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp 
set writebackup
cpjolicoeur
+4  A: 

Try :set noswapfile, or without the ":" in your vimrc file. For more details see the Vim docs on swapfile

dwc
Thanks dwc for the answer
Nadia Alramli
+1  A: 

I found the answer here http://www.vim.org/htmldoc/recover.html.

vim -n opens file without swapfile

set dir=/tmp in .vimrc creates the swapfiles in /tmp

markus_b
A: 

You can set backupdir and directory to null in order to completely disable your swap files, but it is generally recommended to simply put them in a centralized directory. Vim takes care of making sure that there aren't name collissions or anything like that; so, this is a completely safe alternative:

set backupdir=~/.vim/backup/
set directory=~/.vim/backup/
monokrome