4

I'm working on a Quarto document in RStudio/Posit where I frequently need to insert recurring formatting code. I've set up some custom code snippets in RStudio that work perfectly inside code chunks. For example, when I trigger the snippet inside a chunk (see screenshot 1), it expands as expected.

However, when I try to trigger the same snippet outside of a code chunk—in regular markdown text—it does not expand (see screenshot 2).

My question is: Is it possible to use predefined code snippets outside of code chunks in Quarto? In other words, can these snippets be triggered in plain markdown sections, or are they limited to code chunks only?

Any guidance or workarounds would be appreciated.

Screenshot 1:

enter image description here

Screenshot 2:

enter image description here

2 Answers 2

5
+50

Try using shift + tab instead of only tab :)

Unfortunately this doesn't show a dropdown menu but it will work when the typed characters already defines a snippet uniquely.

For example ! + shift + tab will not do anything but ![ + shift + tab will expand to the integrated ![label](location) snippet.

2
  • thank you very much for your answer! However, using the Shift + Tab combination did not make any difference. With the chunk it behaves as you have described!
    – TarJae
    Commented Mar 8 at 13:32
  • 2
    Ok. I sincerely apologize—Shift + Tab does work, of course. The problem was that I saved the snippets in R, but they actually need to be added in R Markdown. You have to go to Tools → Edit Code Snippets, select Markdown on the left side, and add the snippets there. A beginner’s mistake! May you could add this to your answer!
    – TarJae
    Commented Mar 9 at 7:43
2

Expanding on what has already been said. shift + tab should do the trick for you. The Code Snippets - Rstudio User Guide mentions that markdown snippets lack tab code completion. You'll need to type the entirety of the snippet name before shift + tab will insert the snippet. In this case my_quarto_columns

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.