3

Is there a command/macro/keyboard shortcut that will expand the region where the cursor is and expand all collapsed regions inside it (recursively) ? if not can that be achieved ?

ΩmegaMan
  • 26,526
  • 10
  • 91
  • 107
kofifus
  • 14,411
  • 12
  • 82
  • 140

3 Answers3

5

Short answer

As far as I know - No. There isn't a single shortcut that does that.

How to implement it by yourself

It's quite easy to create a plugin for Visual Studio that does exactly that:

  1. Get the cursor location.
  2. Store the 'start' and 'end' line numbers
  3. For each line:
    • If it contains a region - expand it.

Few examples to begin with:

Some of the projects are very close to the thing you have in mind, so you might even fork it and do your changes.

:-)

Another option

you might get the same result by using Macros for Visual Studio Editor/Recorder:

And then, write a macro like this one or maybe even record the steps you like to "run".

IMO, with recording and playing it will be a little harder to achieve. but I'll be happy to be proved wrong.

itsho
  • 4,305
  • 3
  • 43
  • 64
0

I had the same problem, the following worked for me without having to make a macro or a plugin. Note, this is only a partial solution to the problem. I got it to expand recursively underneath a function, but I'm not sure how to reverse it (i.e. recursively collapse everything under the function again). To recursively collapse everything again, I could only figure to use (Ctrl+M, Ctrl+L), which collapses/expands everything in your file, but then you have to drill back down to the function you want.

Firstly, I got everything in a collapsed state by pressing (Ctrl+M, Ctrl+L). You may have to use that combination twice to get everything to collapse. Then I expanded a class and drilled down to the function I wanted to work on.

With the function in its collapsed state, I highlighted the single collapsed row it was on and pressed (Ctrl+M, Ctrl+M).

Doing so recursively expanded everything under the function.

I hope this partial solution helps someone who doesn't want to make a macro or plugin.

RBT
  • 21,293
  • 19
  • 144
  • 210
Dan
  • 1
  • 2
-1

I believe ctrl + k followed by ctrl+] should unfold all subregions

replacing the ] with [ should fold all subregions.

loganrussell48
  • 1,339
  • 2
  • 12
  • 22