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

8

是否可以在使用VSCode编写Quarto文档时添加R代码块的键盘快捷方式?

我想要使用像管道操作符%>% (ctrl+shift+m)等快捷方式。我以为我可以通过将下面的代码包含在keybinds.json文件中来实现,但是它对我不起作用:

    {
      "key": "ctrl+shift+m",
      "command": "type",
      "when": "editorLangId == 'r' || editorTextFocus && editorLangId == 'qmd'",
      "args": { "text": " %>% " }
    },

|| 的优先级低于 &&,没有 (),因此请写出布尔表达式。 - rioV8
1个回答

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"
  }
]

按下Ctrl+Shift+m可以把"%>%"放在光标当前位置。


"keybinds" 确实是个打字错误。你的回答对我有用,谢谢! :) - Raul De Sá Durlo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接