> I would like to have date.time stamped backups.
>
> How is that done within vim?

This is the script I use presently:

function! StampBackup()
    let bup = globpath(&backupdir, expand('%:t') . &bex)
    if bup != ""
        let stamp = ".".strftime("%y.%m.%d_%H.%M.%S")
        if expand('%:t') =~# '\M.'  " maybe use =~? on windows
            let stamped =
        \ substitute(bup, '\M.\(\[^.]\*\)' . &bex . '$', stamp . '.' .
'\1', '')
        else " file has no suffix
            let stamped = substitute(bup, '\M' . &bex. '$', stamp,
'')
        endif
        if rename(bup, stamped)
            echoerr "failed rename of backup " . bup . " to " .
stamped
        endif
    endif
endfunction

augroup StampBackup
    au! BufWritePost,FileWritePost * call StampBackup()
augroup END

(The fancy renaming is to keep the extension at the end so that vim's
file type recognition works.)

The obvious deficiency is that information about the location of the
edited file is not kept, so if you have the same name in use in
several places  (f. ex. Makefile) it's problematic telling them
apart.  I like the idea of using a VCS, it's what they're for.  I'll
likely move to that approach when I get familiar enough with a modern
VCS.

I suggest having a look in the vim tips wiki,
http://vim.wikia.com/wiki/Special:Search?search=backupdir&go=Try+exact
  and there's some scripts at vim.org.

Regards, John

-- 
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

Reply via email to