Shortcut: Select all in current R Markdown code chunk

rmarkdown
rstudio
feature-request

#1

It would be handy to have a menu command/shortcut that would let users select all the code in a chunk. For example, I might have a large chunk that runs some models, then some text, some more chunks plotting model effects; if I then want to replicate the large models chunk, it's a bit cumbersome to drag my mouse over it to select all the text. Does this functionality exist?


#2

I am not sure this feature exist. One trick when I need this is to fold the chunk ans select when it is folding using keyboard shorcut (SHIFT + CTRL + :arrow_right:) to select from } up to the next {.
image

One other trick is to select line by line with SHIFT + CTRL + :arrow_down:

Also, if you want to re-use the exact same chunk of code elsewhere in the document, there is knitr feature to reuse some chunk code in another chunk.

  1. Name the chunk
  2. use ref.label=<name of the chunk to reuse> chunk option in the other chunk.
```{r some-code, results = 'hide'}
1 + 1
```
```{r ref.label='some-code', echo = FALSE}
```

For a RStudio feature, we'll see if someone knows about it. Otherwise, you can submit one : Writing Good Feature Requests