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 especia
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/
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.
To disable swap files from within vim, type
:set noswapfile
To disable swap files permanently, add the below to your ~/.vimrc
file
set noswapfile
For more details see the Vim docs on swapfile
I found the answer here:
vim -n <file>
opens file without swapfile.
In addition:
set dir=/tmp
in .vimrc
creates the swapfiles in /tmp
.
create no vim swap file just for a particular file
autocmd bufenter c:/aaa/Dropbox/TapNote/Todo.txt :set noswapfile
I agree with those who question why vim needs all this 'disaster recovery' stuff when no other text editors bother with it. I don't want vim creating ANY extra files in the edited file's directory when I'm editing it, thank you very much. To that end, I have this in my _vimrc
to disable swap files, and move irritating 'backup' files to the Temp dir:
" Uncomment below to prevent 'tilde backup files' (eg. myfile.txt~) from being created
"set nobackup
" Uncomment below to cause 'tilde backup files' to be created in a different dir so as not to clutter up the current file's directory (probably a better idea than disabling them altogether)
set backupdir=C:\Windows\Temp
" Uncomment below to disable 'swap files' (eg. .myfile.txt.swp) from being created
set noswapfile