Last active
December 14, 2015 17:38
-
-
Save tmsanrinsha/5123363 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set backup | |
set backupdir=~/.vim.d/.bak | |
augroup backup | |
autocmd! | |
autocmd BufWritePre,FileWritePre,FileAppendPre * call UpdateBackupFile() | |
function! UpdateBackupFile() | |
let basedir = expand("~/.vim.d/.bak") | |
let dir = strftime(basedir."/%Y%m/%d", localtime()).substitute(expand("%:p:h"), '^C:', '' , '') | |
if !isdirectory(dir) | |
call mkdir(dir, "p") | |
endif | |
exe "set backupdir=".dir | |
let time = strftime("%H-%M", localtime()) | |
exe "set backupext=.".time | |
endfunction | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment