3

I'm using R Studio desktop and trying to use code folding. My code looks like this:

# first ----
test1 <- 1

# second ----
test2 <- 2

# third ----
test3 <- 3

# fourth ----
test4 <- 4

When it folds, I want it to look like this:

# first <>

# second <>

# third <>

# fourth <>

But instead, it looks like this:

# first <>
# second <>
# third <>
# fourth <>

Is there a way to make R Studio not include the last blank line in the fold? I don't remember this being an issue when I was using R Studio Server, but I can't confirm that at this time.

  • This is curious. Look at [the example](https://support.rstudio.com/hc/en-us/articles/200484568-Code-Folding-and-Sections) at Rstudio. Specifically, check out the third picture. The code folds and leaves a blank line afterwards, as you'd like. When I try this, however, I get the same result as you. – Dan Sep 20 '17 at 15:11
  • So, I think how they produced that demo was to write a code section, fold it, insert a blank line, and then write another section. This creates a blank line between the sections. Nevertheless, when you unfold and refold the section, the blank line will get folded into the preceding code section. – Dan Sep 20 '17 at 15:18
  • I see. Seems odd that this is how R Studio would implement code folding though. Blank lines make the sections much more readable IMO. – VagueAdvice Sep 21 '17 at 14:24
  • I completely agree. Perhaps file a bug report? – Dan Sep 21 '17 at 14:27

0 Answers0