Q:

How do I had an alias for magrittr pipe from R in vscode

I would like an alias for typing %>% in vscode (the pipe command in R) .  In Rstudio this is mapped to ctrl + shift + M, but if this is not available in vscode for any reason I am happy to map to something else, I am just not sure how to add a new alias. 

A:

You only need to add this to your keybindings.json file (see here to know how to open it):
{
  "key": "Ctrl+Shift+m",
  "command": "type",
  "args": { "text": " %>% " },
  "when": "editorTextFocus"
}

This way you don't need macros

keybindings.json file after modification:
// Place your key bindings in this file to override the defaults
[
    {
        "key": "Ctrl+Shift+m",
        "command": "type",
        "args": { "text": " %>% " },
        "when": "editorTextFocus"
    }
]

