Thank you very much for this suggestion. I think I will map this 's' 
command to an available <F...> key. An additional question, if you do not 
mind: why

submatch(1), submatch(1)

and not

submatch(1), submatch(2)

Thank you again!
guido

On 2020-06-23 09:56, Guido Milanese wrote: 

> > 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. 
>
> Assuming the notation <var> for your variables, you could do 
> (automate) something like the following 
>
>   :%s/<TODAY>/\=strftime('%c')/ge 
>   :%s/<AUTHOR>/\=$USER/ge 
>
> If you have a lot of them, you could simplify them to a single 
> replacement with something like 
>
>   :%s/<\([^>]*\)>/\=get({'TODAY':strftime('%c'), 'AUTHOR':$USER}, 
> submatch(1), submatch(1)) 
>
> putting as many tokens and their respective values as you want in 
> that hard-coded dictionary/mapping. 
>
> -tim 
>
>
>
>
>
>
>

-- 
-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/974851d2-a371-4ad7-a919-fc462cde026eo%40googlegroups.com.

Reply via email to