Set A Backup Folder For Vim

As I have mentioned here, Vim creates backups for the files edited everywhere.

To avoid this, you can set the backupdir or bdir variable to tell Vim where to put its backups. The default path for the backupdir is the current dir (.), ~/tmp and the homedir (~/) .

I will set my vim backups to: ~/.vimbackup and ~/tmp:

$ set backupdir=~/.vimbackup,~/tmp,~/ >> ~/.vimrc
$ mkdir -p ~/.vimbackup
$ chmod u+w ~/.vimbackup

This way, if you want your backups to be neatly grouped. If your directory does not have write permissions, vim will save the swap files to ~/tmp. In worst case scenario, the backups will get to my ~.

Tagged with: , , , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *




Subscribe to get the latest Linux news and how to guides directly on your e-mail!