Saturday, December 19, 2009

backup filename including date+time (was: Setting up my vimrc)

* kennethadammiller <kennethadammiller@gmail.com> [2009-12-20 04:54]:
> I'm a beginner and newbie to vim.
> I was just going to ask about how to set up my vimrc to
> backup files to a directory that is depended on the date
> with a file extension that is dependent on the time.
> This is the current contents of my vimrc.
>
> set nocompatible autoindent ruler incsearch history=300 so=4
> syntax enable
> filetype on
> set patchmode=.orig
> set backup
> let &backupdir="/home/adam/Shortcuts/Backups/" . strftime("%y%m%d")
> let &backupext=strftime("%H%M%S") . ".bak"
>
> I was guided to use :let &back... by some
> good folks on the IRC channel...
> whenever I try to do it, though, I get
> "E510: Can't make backup file (use ! to override)"

so.. you are creating a name for a *directory* -
but where is the command that *creates* it, too?
vim does not creates directories for you - sorry!

> how do i get it to do what I want?

i suppose you need to run a command that
creates the directory before you use it:

:!mkdir &backupdir

i think you should have added the year+month+day
as part of the filename rather than the directory:

let &backupdir="/home/adam/Shortcuts/Backups/"
let &backupext=strftime("%y-%m-%d.%H%M%S.bak")

mind you: untested. just some ideas.

Sven

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

No comments: