I recently switched to quarto for reporting with r. The only problem is that in vscode, I cannot send multiple lines of code to the terminal as I am used to.
In .Rmd and .R documents, I can use Cmd Enter with the cursor on any line of a connected multi-line bit of code and it gets exectuted. I can also highlight a part and execute only that. Both behaviors do not work for .qmd documents.
In .qmd documents, the only way to execute these kinds of statements is to highlight the entire part, or have the cursor one line above the first code line. That I cannot send highlighted parts is also quite annoying.
# would only execute with the cursor one line above or all highlighted
diamonds %>%
arrange(carat)
# also does not work --> not only pipe commands
purrr::map(diamonds$carat,
exp)
My settings are as follows:
{
[...]
"r.bracketedPaste": true,
"r.rterm.mac": "/usr/local/bin/radian",
"r.lsp.debug": true,
"r.lsp.diagnostics": true,
"files.associations": {
"*.Rmd": "rmd"
},
"quarto.mathjax.theme": "dark",
"quarto.render.previewType": "external"
[...]
}
I have the same problem on a Mac and Ubuntu, so I suppose it's not system dependent. Would be great if anybody could point me to a solution. Thanks!
CodePudding user response:
You can the R extension's command in Quarto too by adding a keyboard shortcut as described here:
{
"key": "ctrl enter",
"command": "r.runSelection",
"when": "editorTextFocus && editorLangId == quarto || editorLangId == r"
}