I dislike Vim cluttering my working directory with backup and swap files, but I don't want to turn them off in case something crashes. I found that adding lines like:
set backupdir=./.backup
set directory=./.backup
in the Vim .vimrc configuration file tells Vim to put those files in a hidden directory. This is great except that if I do not manually create these hidden directories, it seems Vim does not create backup or swap files. I saw somewhere else lines like:
set backupdir=./.backup,/tmp,.
set directory=./.backup,/tmp,.
and thought that this would tell Vim to use the other locations, /tmp
or .
, if it cannot use ./.backup
, but Vim does not seem to do so.
How would I make Vim either:
- create the needed
./backup
directory, or - use the working directory if the
./backup
directory does not exist?