Sunday, June 28, 2020

Re: Date in a boilerplate file

On 2020-06-28, Guido Milanese wrote:

> Il giorno sab 27 giu 2020 alle ore 16:43 Mateusz Okulus ha
> scritto:
>
> On Tue, Jun 23, 2020 at 09:56:34AM -0700, Guido Milanese wrote:
> > In a project I am developing, I have written some boilerplate files to be
> > used as headers for Markdown/LaTeX documents. One of the lines contains
> the
> > document date, and ideally it should be:
> >
> > date: <TODAY>
>
> I think it's easier to use unix tools instead of vim for this.
>
> sed "s/<TODAY>/$(date)/g" [file]...
>
> You can specify multiple files, and make changes permanent
> with -i flag.

> Thank you. I was indeed considering something like this -- perhaps a srot of
> "preprocessing" of the file.

What I used to do was embed my boilerplate text as a here-document
in a shell script which the script cat'ed into a pipeline of sed
and/or awk scripts to add the date, author name, etc. Then I just
sourced the output of that script into Vim with a ":r!" command.
That kept everything in one file.

The only reason I no longer do that is that my recent jobs haven't
required the creation of a lot of new files with a common
boilerplate format.

Regards,
Gary

--
--
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 on the web visit https://groups.google.com/d/msgid/vim_use/20200629003332.GA17697%40phoenix.

No comments:

Post a Comment