1

I am using VS 2017 with R Tools for Visual Studio, and I wonder if there is a way to create expandable code sections such as in RStudio:

#### My region ####
[...]
####           ####

I also tried #region and #endregion, which used to work with some others of the "Tools for Visual studio", but without success.

Hong Ooi
  • 56,353
  • 13
  • 134
  • 187
Antoine C.
  • 3,730
  • 5
  • 32
  • 56

1 Answers1

2

I finally found out that to define a new code region, you must write a line that matches the following pattern (regex): ^\s*#.*---\s*$.

  • Zero or more leading whitespace characters
  • One hash #
  • Any character, zero or more times
  • Three hyphens - (and not 4 hyphens, hashs or equal signs like in RStudio)
  • Zero or more trailing whitespace characters

By beginning another section, it will end the previous one and make it a block you can collapse.


So for instance you can make a new section like this:

# My section ---
    [...]
# ---
Antoine C.
  • 3,730
  • 5
  • 32
  • 56
  • but how do you end the section? Adding `# My section ---` to my code means *My section* goes to the end of my script. – lebelinoz Aug 10 '17 at 06:16
  • By beginning another section, it will end the previous one and make it a block you can collapse, see the edit. – Antoine C. Aug 10 '17 at 07:34