VS Code中没有Rstudio中默认的快捷键,比如赋值符<-
(Rstudion中快捷键是alt + -
)、管道符%>%
(Rstudion中快捷键是shift + ctrl + M
),如何自定义?
1、在VS Code中,shift + ctrl + P
,在出现的搜索栏中输入“快捷键”
2、选择《首选项:打开键盘快捷方式》
3、在打开的keybinding.json文件的[]
中填入以下代码
{
"key": "ctrl+shift+m",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && editorLangId == 'r'",
"args": {
"snippet": " %>% "
}
}
{
"key": "alt+-",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && editorLangId == 'r'",
"args": {
"snippet": " <- "
}