Why VIM backup filenames are not correct? 'backupdir' option not performing as expected

前端 未结 5 376
刺人心
刺人心 2021-01-04 04:15

I\'m building a custom vimrc to improve my workflow, and I really liked the idea of setting a centralized directory to keep all backup, swap and undo files together, like th

5条回答
  •  清歌不尽
    2021-01-04 04:56

    I add this answer because I find it really frustrating.

    This could be a work-around until Vim add the path translation functionnality to backupdir. What I did is adding the following line to my .vimrc :

    autocmd BufWritePost * :execute ':w! ' ."$HOME/.vim/backups/" . substitute(escape(substitute(expand('%:p'), "/", "%", "g"), "%"), ' ', '\\ ', 'g')
    

    Basically, everytime you save a file, it will also save a copy in $HOME/.vim/backups.

提交回复
热议问题