3

Is it possible in Visual Studio 2017 to collapse the code in a Case of a vb.net Select without adding Regions to each Case?

I am working on adding to some legacy code that has a Select that runs to about 1,500 lines... Not really interested in going through and adding Regions to every Case especially as it's pretty evident that others working on this code have no idea what they are

I see that by default there are no collapse markers but I'm hoping that there may be some setting where what can be collapsed can be adjusted maybe?

EDIT: Found I can select the Case body then Ctrl+M, H... Any better way than this that I can specifically set collapsability for Cases?

EDIT: I also found this tool but it dates from VS2010 so I'm thinking it likely won't work with VS2017. There are instructions on making onse own outliner here and here but that's more work than I have time for ATM.

Toby
  • 9,696
  • 16
  • 68
  • 132
  • 2
    `Any better way than this...` With a 1500 line case statement, I would consider a dictionary (or set of them) or even a LookUp – Ňɏssa Pøngjǣrdenlarp Apr 12 '17 at 16:02
  • I would address the code at hand if at all possible. That's a lot of lines. – Bugs Apr 12 '17 at 16:02
  • @Plutonix If I had a choice I'd just do away with it altogether. There's actually only about 25 cases, but nothing calls functions anywhere, everything that a case should do is coded directly in the case body >. – Toby Apr 12 '17 at 16:06
  • I probably will eventually refactor this entire application, but that's for after I have new functionality added as the application is in production and the new stuff is needed now. – Toby Apr 12 '17 at 16:08
  • 1
    This may help http://stackoverflow.com/questions/982677/visual-studio-command-to-collapse-all-sections-of-code?rq=1. It may even be a duplicate but not sure if an exact duplicate. – Bugs Apr 12 '17 at 16:09
  • 1
    @Bugs Sadly this does not work for Cases, except for using the already mentioned Ctrl+M,H. A lot of the info on SO already works for C# because the editor can collapse on `{}` blocks, but VB doesn't have these – Toby Apr 12 '17 at 16:20
  • Answer here says this is not supported for VB :( http://stackoverflow.com/a/15070387/1292918 – Toby Apr 12 '17 at 16:24

1 Answers1

10

According to this article you can.

Select a code block and do Ctrl+M+H to mark as a foldable section. With Ctrl+M+U you can remove the marker.

It works in VS2015.

Tonko Boekhoud
  • 819
  • 6
  • 9