How to prevent vim from creating (and leaving) temporary files?

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

Leave a Comment