Search code examples
rstudioquarto

Can I add quarto snippets in the RStudio IDE?


I would like to add these Quarto code snippets to the RStudio IDE:

# quarto callout note
snippet con
    :::{.callout-note appearance=minimal}
    ${1:text}
    :::

# quarto callout warning
snippet cow
    :::{.callout-warning appearance=simple}
    ${1:text}
    :::

The editor will only expand the snippets if the text is inside a code chunk. Is there a fix/work-around to allow snippets in plain text?


Solution

  • These snippets are expanding only inside the r-code chunk for your case, probably because you have defined these snippets in the R snippet. Instead, You need to add these snippets for Markdown to get these work.

    So go to Tools > Global Options > Code > Editing > Edit Snippets, and then go to the section Markdown and paste these snippets there. Save, OK, apply.

    Now after writing con in qmd file and then press shift + Tab.


    Also be careful about pasting the snippet, so that any extra space doesn't get pasted with these. (While I tried to paste these snippets, these didn't work at first, because of extra spaces were pasted before :::)