Good! Now I think I have understood (at last...) how to use autocmd!
guido

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 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. 
>
> I would have the template as you have it above, and an autocmd on 
> "BufNewFile *.md,*.latex" or whatever, that inserts it, with "0r file", 
> then does a substitution of "<TODAY>" with "\=system('date')" or whatever 
> you want. It would have been quicker to just write it than explain it: 
>
> autocmd BufNewFile *.md,*.latex 0r $HOME/.vim/templates/markdown-latex.txt 
> | %s/<DATE>/\=system('date')->trim()/eg | normal G 
>
> Or something :) 
>

-- 
-- 
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/a98f5862-0120-4baf-a4e2-9b20876c2f1do%40googlegroups.com.

Reply via email to