Thursday, July 2, 2020

Re: Date in a boilerplate file



On Tuesday, June 23, 2020 at 11:56:34 AM UTC-5, 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 know how to insert date from command line, but is it possible to embed the command in the boilerplate file and have it transformed into the real date? I tried autocmd to no success -- clearly I have not really understood how to use it!
The same applies to other fields (such as AUTHOR), but the DATE field is the most important one.
Thank you!
guido (Northern Italy)



You have some good suggestions already that use hard-coded substitute commands in the autocmd. A more versatile method would be to embed the expressions you want evaluated right in your template file: https://vim.fandom.com/wiki/Use_eval_to_create_dynamic_templates

Of course there are also a wide variety of template plugins that might be a good fit for you, too.

--
--
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/e14f3cb1-e4a4-4488-9879-ca2b377b005eo%40googlegroups.com.

No comments: