Skip to content

Instantly share code, notes, and snippets.

@iley
Created February 4, 2013 13:21
Show Gist options
  • Select an option

  • Save iley/4706707 to your computer and use it in GitHub Desktop.

Select an option

Save iley/4706707 to your computer and use it in GitHub Desktop.
" save «smart» backups every day
function! BackupDir()
let l:backupdir=$HOME.'/.vim/backup/'.
\substitute(expand('%:p:h'), '^'.$HOME, '~', '')
if !isdirectory(l:backupdir)
call mkdir(l:backupdir, 'p', 0700)
endif
let &backupdir=l:backupdir
let &backupext=strftime('~%Y-%m-%d~')
endfunction
autocmd! bufwritepre * call BackupDir()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment