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?
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 + ) to select from }
up to the next {
.
One other trick is to select line by line with SHIFT + CTRL +
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.
- Name the chunk
- 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
1 Like