Sunday, March 9, 2025

Re: update last-modified, but record changes only if :w

On Sun, 09 Mar 2025, 'sukolyn' via vim_use wrote:

> hi,
>
> I catched this little code to update last-modified content in HTML files
>
> : au FileType x*html
> :    \ exe
> 'g/http-equiv="last-modified"/s/content=".*/content="'.strftime("%Y-%m-%d
> %T").'">'
>
> the problem is this happens even I don't record file (:w), and so date
> changes even there are no changes.
> this doesn't make much sense, does it? :)
>
> how could I make update recorded only if I write to file?

You may want to use a BufWritePre autocommand instead.

Thanks,
Christian
--
If rabbits' feet are so lucky, what happened to the rabbit?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/Z81V/rot2BKMZXhq%40256bit.org.

No comments: