I don't like how vim clutters up my folders with backup files, so I have the following line in my .vimrc file:
set backupdir=~/.vim_backup
However, sometimes this folder doesn't exist because of new machines where I am copying my user files over.
How can I create this folder automatically, if it doesn't exist, from within .vimrc? Or is there some better way to deal with this situation?
mkdir: cannot create directory – Permission denied The reason for this error is that the user you're running the mkdir as, doesn't have permissions to create new directory in the location you specified. You should use ls command on the higher level directory to confirm permissions.
I think this is operating system independent:
if !isdirectory("/my/directory") call mkdir("/my/directory", "p") endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With