How to create a shortcut for promise pipe %...>%

The simplest option is to make a code snippet with a very short trigger. Pressing Shift+Tab after typing the entire trigger will immediately insert the snippet, and you can control the post-insert cursor position from the snippet definition.

To get a true keyboard shortcut (with command key modifiers) for an arbitrary snippet of text, you can make an RStudio Add-In, which can be assigned to keyboard shortcuts.
https://rstudio.github.io/rstudioaddins/
Inserting snippets via keyboard shortcut is one of the intended use cases for add-ins and there are already packages out there that include useful common bits of text, such as remedy for inserting Markdown formatting. The addinslist add-in can help you find more cool add-ins.

Maybe somebody else has already done an all-the-magrittr-pipes add-in? If not, maybe you could contribute one! :grin:

8 Likes