1

Is there a shortcut or an add-in to format multiples lines of codes into one single line and vice versa in RStudio ? Such as in the following image :

Goal enter image description here

Toy Code

#### Singles lines ####
a <- 1; b <- 2; d <- 5;

ggplot(mtcars, aes(x = gear, y = disp, group = gear)) + geom_bar(stat = "identity")

mtcars %>% filter(gear == 4) %>% nrow()

#### Multiple lines ####
a <- 1
b <- 2
d <- 5

ggplot(mtcars, aes(x = gear, y = disp, group = gear)) + 
  geom_bar(stat = "identity")

mtcars %>% 
  filter(gear == 4) %>% 
  nrow()

I already knew and installed the remedy package but it returns an error message when I click on the add-in.

Julien
  • 1,613
  • 1
  • 10
  • 26
  • 1
    `Ctrl + Shift + A` launched on selected lines can help transforming one line into multiple line. Though it won't work correctly for all code. – Yacine Hajji May 18 '22 at 08:33
  • 1
    @YacineHajji It does not answer my question totally, but thanks for the nice tip – Julien May 19 '22 at 12:48

0 Answers0