In RStudio
, there is a snippet as follows:
snippet ts
`r paste("#", date(), "------------------------------n")`
It will pastes some texts by running date()
,
for example,
# Sat Oct 15 11:04:22 2022 ------------------------------
.
How to define this in VScode
?
2
Answers
With extension File Templates you can create a key binding that insert a template with date variables.
Create a date format you want and the template that uses that date format.
Here is a way to do this in any type of file. You will need this extension (that I wrote), Find and Transform. Make this keybinding (in your
keybindings.json
):You can use any of the
Intl.DateTimeFormat
options.Note the use of
${LINE_COMMENT}
at the beginning of the string. That will resolve to the comment style of whichever language you are in at the time. The demo is in anr
file.