No need to mess with $cfilname.

I have a write-hook that saves numbered backups (file~#~, where # is 1, 2,
3, etc.) by
simply passing the filename to some code that makes a copy of the file
using the
next unused number and preserving the mod time.

--mike

On Fri, Apr 5, 2024 at 2:46 PM Thomas Dickey <dic...@his.com> wrote:

> On Thu, Apr 04, 2024 at 08:01:01PM +0000, david sowerby wrote:
> > Hi, in Vim/Neovim I can save a copy of the file when I exit. The copy is
> renamed file-$(date +%s).bak. This gives me a file with an increasing
> number plus .bak. It looks like "date+%s" and  "&stime" do the same thing.
> Is this possible in vile? I know I can save a file as file.bak but I like
> to save a series of changed files, not just one.
> > So a macro that saves a copy and I then call that macro with
> write-hook.  Thanks.
>
> write-hook is called before a file is written (so I don't think it would
> work
> just like the suggested order).
>
> But you could have a macro which decides what the filename should be,
> and writes to that.  The macro should save and restore $cfilname,
> otherwise $cfilname will get updated to point to the most recently
> written file.
>
> --
> Thomas E. Dickey <dic...@invisible-island.net>
> https://invisible-island.net
>

Reply via email to