How can I read a file into the current buffer and do some template substitution on it automatically?
I'm working on a simple bash-driven logging / journaling capability. (on github, fyi)
I have a file that contains a templated todo item called
daily.tmpl as follows:
- [ ] Check this weeks todo: 2020-$WW.md
I would like to be able to read that into my daily todo, and substitute
$WW with the week.
I can capture the week number using
date +%W. Or in vim:
:let weeknumber=date +%W (with appropriate escaping omitted for clarity).
I can read the templated file to the top using
So, I have created a bash alias that can open a daily todo item with a file name by date as:
alias todo=vim -c 'read daily.tmpl' `date`
What command can I execute to substitute, after read,
$WW for the local vim variable
Is there another, better way to do this?