RStudio snippet not working
Asked Answered
S

3

7

I'm utilizing a Macbook pro running "El Capitan" and RStudio is version 0.99.902. I'm writing a Rmd document. I want to utilize the snippets that RStudio has built in and create my own also. By clicking Preference => Code; I can see that "Enable code snippets" is checked. However, while trying to utilize any snippet the completion is not performed. If I typed just r I should get this block of code, but nothing hapen

snippet r
    ```{r ${1:label}, ${2:options}}
    ${0}
    ```

I also create a simple snippet:

snippet dthen
    %>%

None of the markdown snippet seems to work. Do I'm doing something wrong or any setting has to be done?

Swound answered 10/6, 2016 at 12:38 Comment(1)
Same problem here using RStudio Server Pro or RStudio Desktop for Mac (El Cap). R snippets inside code blocks work, but snippets outside code blocks (Markdown snippets) do not work.Flak
F
6

You can invoke code snippets in Markdown in RStudio using Shift+Tab after typing the snippet, but it will not currently prompt you to expand the snippet, either with Tab or by just waiting. I thought this was a bug, but the discussion in this GitHub issue says it's intended, just still-to-be-documented.

Flak answered 26/8, 2016 at 16:32 Comment(1)
Not really a solution, but perhaps you can make it work. Have a look hereFen
T
1

In Tools > Global Options > Code > Editing > Edit Snippets, go to the section "Markdown" and paste your snippet there. Save, OK, apply. Type r in your Rmd document (not within in a R code chunk) and click Shift+Tab. If it still does not work, try to create a new "R markdown" file (File > New file > R markdown) and check if it works there.

Thickskinned answered 4/11, 2020 at 14:57 Comment(0)
I
0

I know this is an old post, but I had the same trouble recently. Snippets must be indented when customized, instead if an space is inserted it won't work

Inhaul answered 11/11, 2023 at 16:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.