使用 VSCode 在 Quarto 文档中添加 R 块的键盘快捷键

Rau*_*rlo 8 r visual-studio-code quarto

是否可以R使用 vscode 为四开文档中的块添加键盘快捷键?

我正在尝试使用管道运算符%>%( ctrl+shift+m) 等快捷方式。我认为我应该通过在文件中包含类似以下代码的内容来做到这一点keybinds.json,但它对我不起作用:

    {
      "key": "ctrl+shift+m",
      "command": "type",
      "when": "editorLangId == 'r' || editorTextFocus && editorLangId == 'qmd'",
      "args": { "text": " %>% " }
    },
Run Code Online (Sandbox Code Playgroud)

Mau*_*ers 9

我认为keybinds.json您的帖子中有一个拼写错误(正确的文件名是keybindings.json)。

如果我正确理解了你的意思,这是我的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)

然后按 Ctrl+Shift+m​​ 将“%>%”放置在光标的当前位置。