breakerofchains or similar for Positron

One of my all-time favorite R packages is Miles McBain's breakerofchains.

You can put your cursor anywhere in a piped command, run a keyboard shortcut, and RStudio will run everything up to the current line. This prevents so much time highlighting up to a point and running partial pipeline code.

Does anything like this exist for Positron?

E.g., if the cursor is anywhere on the select() line, the keyboard shortcut will run up to the select, but not the summarise or after.

library(tidyverse)

star_plot <-
  starwars %>%
  group_by(species) %>%
  select(height, mass) %>%  ### putting the cursor here will stop after the select()
  summarise(
    height = mean(height, na.rm = TRUE),
    mass = mean(mass, na.rm = TRUE)
  ) %>%
  ggplot(aes(x = height, y = mass)) +
  geom_point()
1 Like

I believe this package should work well in Positron, because we support all the rstudioapi functions that are used. You would need to set up a custom keyboard shortcut something like this:

{
    "key": "Ctrl+Shift+B",
    "command": "workbench.action.executeCode.console",
    "when": "editorTextFocus",
    "args": {
        "langId": "r",
        "code": "breakerofchains::break_chain()",
        "focus": true
    }
1 Like

Thanks Julia!

The one thing I changed was "focus": false so that the focus stayed in the editor rather than jumping down to the console.

Thank you for this! This too is one of my favorite workflow packages and I also hadn't set it up yet with Positron. Loving Positron more each day!

I'd also like to give an honorable mention to a feature called Selection Range, which is bound to Ctrl + Shift + Right to "expand" and Ctrl + Shift + Left to "shrink" on a Mac by default.

You select a range and then Cmd + Enter to send it to the console

It is quite useful as a native breakerofchains feature!

1 Like

Ooooh... this is magical :crystal_ball: