VSCode: Add "cmd-shift-m" keyboard shortcut for "%>%" (pipe operator) for R development

RStudio uses the "cmd-shift-m" keyboard shortcut to insert the tidyverse pipe operator (%>%). If you are using VSCode to write R code, it's nice to have this there too. Here's what you need to add to keybindings.json to get this into place:

    {
        "key": "shift+cmd+m",
        "command": "-workbench.actions.view.problems"
    },
    {
        "key": "shift+cmd+m",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "snippet": "%>% "
        }
    },
    {
        "key": "shift+cmd+m",
        "command": "workbench.action.terminal.sendSequence",
        "when": "terminalFocus",
        "args": {
            "text": "%>% "
        }
    }

🌟 Was this page helpful? Please let me know with this quick, 3 question survey.