我想要一个别名来输入%>%vscode(R 中的管道命令)。在 Rstudio 中,这被映射到 ctrl + shift + M,但如果由于任何原因在 vscode 中不可用,我很乐意映射到其他东西,我只是不确定如何添加新别名。
arn*_*nle 11
也可以通过以下方式添加到rmd中
{
"key": "Ctrl+Shift+m",
"command": "type",
"args": { "text": " %>% " },
"when": "editorTextFocus && editorLangId == rmd"
}
Run Code Online (Sandbox Code Playgroud)
并通过以下方式连接到 R 终端
{
"key": "Ctrl+Shift+m",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": " %>% " },
"when": "terminalFocus"
},
Run Code Online (Sandbox Code Playgroud)
这就是我的 settings.json 添加 %>% 和 <- 到我的 Rmarkdowns、Rscripts 和 R 终端(包括弧度)的方式:
[
// OTHER KEYBINDINGS,
// keybindings for R scripts.
{
"key": "Ctrl+Shift+m",
"command": "type",
"args": { "text": " %>% " },
"when": "editorTextFocus && editorLangId == r"
},
{
"key": "Alt+-",
"command": "type",
"args": { "text": " <- " },
"when": "editorTextFocus && editorLangId == r"
},
// keybindings for Rmarkdown
{
"key": "Ctrl+Shift+m",
"command": "type",
"args": { "text": " %>% " },
"when": "editorTextFocus && editorLangId == rmd"
},
{
"key": "Alt+-",
"command": "type",
"args": { "text": " <- " },
"when": "editorTextFocus && editorLangId == rmd"
},
// keybindings for R terminal (radian included)
{
"key": "Ctrl+Shift+m",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": " %>% " },
"when": "terminalFocus"
},
{
"key": "Alt+-",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": " <- " },
"when": "terminalFocus"
},
// OTHER KEYBINDINGS
]
Run Code Online (Sandbox Code Playgroud)
您只需要将此添加到您的keybindings.json文件中(请参阅此处了解如何打开它):
{
"key": "Ctrl+Shift+m",
"command": "type",
"args": { "text": " %>% " },
"when": "editorTextFocus"
}
Run Code Online (Sandbox Code Playgroud)
这样你就不需要宏
keybindings.json 修改后的文件:
// Place your key bindings in this file to override the defaults
[
{
"key": "Ctrl+Shift+m",
"command": "type",
"args": { "text": " %>% " },
"when": "editorTextFocus"
}
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
682 次 |
| 最近记录: |