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

17 views
Skip to first unread message

sukolyn

unread,
Mar 8, 2025, 8:55:41 PMMar 8
to vim...@googlegroups.com




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?

Christian Brabandt

unread,
Mar 9, 2025, 4:49:15 AMMar 9
to vim...@googlegroups.com
You may want to use a BufWritePre autocommand instead.

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

sukolyn

unread,
Mar 9, 2025, 8:54:05 AMMar 9
to vim...@googlegroups.com
Le 09/03/2025 à 09:49, Christian Brabandt a écrit :
On Sun, 09 Mar 2025, 'sukolyn' via vim_use wrote:

how could I make update recorded only if I write to file?
You may want to use a BufWritePre autocommand instead.

Thanks,
Christian

that's it. thank you.

: au BufWritePre * if (&ft == "html" || &ft=="xhtml") | exe 'g/http-equiv="last-modified"/s/content=".*/content="'.strftime("%Y-%m-%d %T").'">' | endif

Reply all
Reply to author
Forward
0 new messages