1 " Borrowed from https://gist.github.com/mllg/5353184
2 " It's like `find ~/.vim/tmp/undo -type f -mtime +31 -delete` but portable
3 function Tmpwatch(path, days)
4 let l:path = expand(a:path)
6 for file in split(globpath(l:path, "*"), "\n")
7 if localtime() > getftime(file) + 86400 * a:days && delete(file) != 0
8 echoerr "Tmpwatch(): Error deleting '" . file . "'"
12 echoerr "Tmpwatch(): Directory '" . l:path . "' not found"
16 " undofile part of your .vimrc
17 if exists("+undofile") && !empty(&undodir) && (&undodir != '.')
18 " remove undo files which have not been modified for 31 days
19 call Tmpwatch(&undodir, 31)