Created
July 23, 2015 10:06
-
-
Save kaero/7377359b104cb4d029d3 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
" dont backup anything if vim launched with root priveleges | |
if $USER != 'root' | |
" create and set backup, swap and undo directories | |
let s:tmp_path = '/tmp/vim_temp/' . $USER . '/' | |
if ! filewritable(s:tmp_path) | |
silent execute '!mkdir -p "' . s:tmp_path . '"' | |
else | |
" remove backups older than 8 days (-ctime +8) | |
silent execute '!find "' . s:tmp_path . '" -type f -ctime +8 -delete' | |
endif | |
au BufWritePre * let &bex = '-' . strftime("%Y.%m.%dT%H:%M:%S") . '~' | |
" double slash in the end of path used to avoid conflicts | |
" between files with equal names (swap and undo files names will contains full path to the file) | |
let &directory = s:tmp_path . '/' | |
let &backupdir = s:tmp_path | |
set backup | |
let &undodir = s:tmp_path . '/' | |
set udf | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment