Reputation: 1241
I have been using the ctrl + shift + m
shortcut to insert well known %>%
pipe operator.
Since the release of R version 4.1.0 and adding a new |>
to base
, I wonder is the corresponding shortcut available in Rstudio?
Upvotes: 53
Views: 26145
Reputation: 752
I found a solution for having shortcuts for both native and magrittr pipes in RStudio (only): addings.
You can get a very detailed description of how addinexamples package works in https://rstudio.github.io/rstudioaddins/
Important: this solution is only valid in RStudio.
Instructions:
devtools::install_github(repo = "https://github.com/LuisLauM/addinexamples")
Ctrl + Shift + ,
but it didn't work, then Ctrl + Shift + Space
did).You can always fork, edit and compile the rstudioaddins package in order to have your own customized shortcuts. You can use my forked version as a guide to determine what files you had to modify. The package allows to create interactive addins, so it is very powerfull.
Upvotes: 4
Reputation: 84
one option that works okay is to add a snippet to your code snippets if you're an rstudio user. You'd then need to hit the snippet name and then tab complete it. The ${0} then drops your cursor one whitespace away from the pipe so you save a keystroke there:
snippet p
|> ${0}
Upvotes: 1
Reputation: 8127
It's the same shortcut. If you install the latest version of the IDE, and go to the Global Options window, select "Code" and you'll see an option for "use native pipe operator, |>". Select that for the shortcut to take effect.
Upvotes: 75