Home > OS >  Add Keyboard Shortcuts for R Chunks in Quarto Docs Using VSCode
Add Keyboard Shortcuts for R Chunks in Quarto Docs Using VSCode

Time:06-29

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": " %>% " }
    },

CodePudding user response:

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.

  • Related