visual-studio-codequartovscode-snippets

Snippet to generate today's date in YAML header of Quarto doc in VS Code using Python


When using Quarto in RStudio I use a snippet to generate a YAML header that prints today's date automatically using the following R code

snippet headerq
    ---
    date: "`r Sys.Date()`"
    ---

Using this headerq snippet will generate the following header:

---
date: "2024-03-03"
---

How can I achieve this same functionality when using Quarto docs in Python in VSCode?


Solution

  • Saving the following snippet worked exactly as needed.

    {
    "Quarto Header": {
        "scope": "",
        "prefix": "headerqp",
        "body": [
        "---",
        "date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE"
        ],
        "description": "Header for Quarto File"
        }