Advertisement
salvoza

vim backups in .vimrc

Aug 14th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. set backup
  2.  
  3. function! BackupDir()
  4. if has('win32') || has('win64')
  5. let l:backupdir=$VIM.'/backup/'.
  6. \substitute(expand('%:p:h'), '\:', '~', '')
  7. else
  8. let l:backupdir=$HOME.'/.vim/backup/'.
  9. \substitute(expand('%:p:h'), '^'.$HOME, '~', '')
  10. endif
  11.  
  12. if !isdirectory(l:backupdir)
  13. call mkdir(l:backupdir, 'p', 0700)
  14. endif
  15.  
  16. let &backupdir=l:backupdir
  17. let &backupext=strftime('~%Y-%m-%d_%H-%M-%S~')
  18. endfunction
  19.  
  20. autocmd! bufwritepre * call BackupDir()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement