Loading ...
Sorry, an error occurred while loading the content.

Re: Backup options

Expand Messages
  • William Natter
    Pawlos, ... I was going to advise you to do this: set backup autocmd BufWritePre * exe set backupext=. .strftime( %Y_%m_%d_%H_%M_%S ) to set you up and have
    Message 1 of 2 , Jan 7, 2004
    • 0 Attachment
      Pawlos,

      >I want that vim when is doing backup add actuallly date.
      >I've tried to use backupext but it don't work as I want.
      >How to do it?
      >Pawlos
      >
      >
      I was going to advise you to do this:

      set backup
      autocmd BufWritePre * exe "set backupext=.".strftime("%Y_%m_%d_%H_%M_%S")

      to set you up and have an up-to-the-second precision on backup time.
      The idea: just before you write your buffer to a file, you set the
      backup extension to whatever the timestamp is.

      But I found out there is an issue... Even when calling "gvim -u NONE -U
      NONE <file>", it seems that Vim makes an error: the backupext variable
      is updated AFTER the buffer name is formed! I wonder if anyone can
      reproduce this. I am using an old version (VIM - Vi IMproved 6.1 (2002
      Mar 24, compiled Jan 17 2003 08:34:22)), which might be the problem.
      Try it out on yours, though, because it should work in principle.

      Hope this helps.

      William
    • Bram Moolenaar
      ... Right, the backup extension is obtained before executing the autocommands. It even looks like setting backupext in the autocommands may cause freed
      Message 2 of 2 , Jan 7, 2004
      • 0 Attachment
        William Natter wrote:

        > Pawlos,
        >
        > >I want that vim when is doing backup add actuallly date.
        > >I've tried to use backupext but it don't work as I want.
        > >How to do it?
        > >Pawlos
        > >
        > >
        > I was going to advise you to do this:
        >
        > set backup
        > autocmd BufWritePre * exe "set backupext=.".strftime("%Y_%m_%d_%H_%M_%S")
        >
        > to set you up and have an up-to-the-second precision on backup time.
        > The idea: just before you write your buffer to a file, you set the
        > backup extension to whatever the timestamp is.
        >
        > But I found out there is an issue... Even when calling "gvim -u NONE -U
        > NONE <file>", it seems that Vim makes an error: the backupext variable
        > is updated AFTER the buffer name is formed! I wonder if anyone can
        > reproduce this. I am using an old version (VIM - Vi IMproved 6.1 (2002
        > Mar 24, compiled Jan 17 2003 08:34:22)), which might be the problem.
        > Try it out on yours, though, because it should work in principle.
        >
        > Hope this helps.

        Right, the backup extension is obtained before executing the
        autocommands. It even looks like setting 'backupext' in the
        autocommands may cause freed memory to be used.

        A quick look didn't show a reason why obtaining the extension can't be
        moved to after executing the autocommands. I'll put this near the top
        of the todo list.

        --
        Very funny, Scotty. Now beam down my clothes.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
      Your message has been successfully submitted and would be delivered to recipients shortly.