之前提到,我从使用RStudio编辑器迁移到了使用VScode编辑器,也是最近几年,VScode才有了相对成熟的R语言支持,但是,有一些方便的快捷键(或者说我用习惯了)没有被初始化设置,所以,需要我手动添加
PS:当然,这里说的常用是我常用的(服务器 Rstudio server),并不涵盖所有
<-
赋值%>%
管道符像什么切换啊,新建啊都内置好了(比如:Ctrl + `,Ctrl + n),但是赋值啊、管道符啊、等等都没有,所以添加一下。
[
//赋值
{
"key": "alt+-",
"command": "type",
"args": {
"text": " <- "
},
"when": "editorTextFocus && editorLangId == 'r'"
},
{
"key": "alt+=",
"command": "type",
"args": {
"text": " -> "
}
},
//特殊作用的
{
"key": "alt+5",
"command": "type",
"args": {
"text": " %in% "
},
"when": "editorTextFocus && editorLangId == 'r'"
},
//管道符
{
"key": "ctrl+shift+m",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && editorLangId == 'r'",
"args": {
"snippet": " %>% "
}
},
{
"key": "ctrl+shift+,",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && editorLangId == 'r'",
"args": {
"snippet": " %<>% "
}
}
]
因为在VScode中使用R语言,有个好用的,类似于Ipython的工具,叫radian
,所以,也贴上一些radian
的设置,直接放在家目录的.radian_profile
配置文件中就OK:
# allows user defined shortcuts, these keys should be escaped when send through the terminal.
# In the following example, `esc` + `-` sends `<-` and `esc` + `m` sends `%>%`.
# Note that in some terminals, you could mark `alt` as `escape` so you could use `alt` + `-` instead.
options(radian.escape_key_map = list(
list(key = "-", value = " <- "),
list(key = "m", value = " %>% ")
))