8

Is it possible to add keyboard shortcuts for R chunks in quarto documents using vscode?

I'm trying to use shortcuts like the pipe operator %>% (ctrl+shift+m) and others. I thought I should do this by including something like the code below in the keybinds.json file, but it doesn't work for me:

    {
      "key": "ctrl+shift+m",
      "command": "type",
      "when": "editorLangId == 'r' || editorTextFocus && editorLangId == 'qmd'",
      "args": { "text": " %>% " }
    },
  • `||` has a lower priority than `&&`, there are no `()` so write out the Boolean expression – rioV8 Jun 28 '22 at 05:11

1 Answers1

8

I assume keybinds.json is a typo in your post (the correct filename is keybindings.json).

Provided I have understood you correctly, here is my 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 then places "%>%" at the current position of the cursor.

Maurits Evers
  • 49,617
  • 4
  • 47
  • 68