See snippet for description
" Replace the default backup behaviour (save backup of `/path/to/file` as
" `/path/to/file~` on overwrite) with saving backup of `/path/to/file` as
" `~/.vim/backup/"file :path:to YYYY.MM.DD hh:mm:ss"` where the overwrite
" occured at hh:mm:ss on YYYY/MM/DD.
"
" This avoids littering backups all over your file system, and lets you go back
" and read multiple backup versions if you desire. It does tend to accumulate a
" lot of backups over time, so it's useful to set a cronjob to periodically
" clear out old backups:
"
" # in crontab
" @midnight find ~/.vim/backup -not -newerat "1 week ago" -delete
let &backupdir = $HOME . "/.vim/backup"
if isdirectory(&backupdir) == 0
call mkdir(&backupdir, "p")
endif
au BufWritePre * let &bex = ' ' . substitute(expand('%:p:h'),'/',':', 'g') . ' ' . strftime("%Y.%m.%d %H:%M:%S")
ReneFroger 11 years ago
Thanks for sharing, but what is the difference with
set backupandset backupdir = ".."?However, with your script, I don't get the timestamp too in the backup files.