Create code chunk from selected text

I can't find how to do this, but it would be great.

I am doing a lot of converting .r scripts to .rmd R Markdown.

This involves creating code chunks.

The flow I have is Ctrl+Alt+i to insert an empty code chunk, then move a section of text into the code chunk.

This would be a lot faster if I could simply select a section of text, then have a keyboard shortcut that "wraps" the selected text in the {r} and thus creating a new code chunk.

This is equivalent to the functionality of selecting text, then typing the quote symbol, and the selected text is surrounded with quotes (which currently is a feature in RStudio).

1 Like

The RStudio Addin called remedy lets you do exactly this (along with lots of other super helpful Markdown shortcuts):

4 Likes

Nice! Thank you! I will definitely install and try this out. Your reply is much appreciated.

1 Like