17

Superfluous qualifier: This is probably a silly question, but...

Using VB.NET and / or C#:
Is there a way to jump to a region quickly, similar to the way you can choose a class and find functions / methods / events from drop-down lists? I have organized thousands of lines of code into neat regions but it seems like a waste if I can't find them quickly.

I now realize Ctrl-M + O (outlining) will basically give me what I was looking for, but the question stands.

Update: Since the community and myself can't seem to find a way to do this, the answer to my question is: No, there is no way to do this. With this knowledge, I won't be so concerned with regions in the future as their usefulness is limited.

Update 2: This question originally applied to VS2010. However it seems to be applicable to later versions as well. At least in 2015, it seems you can quickly jump between regions using keyboard shortcuts.

Relevant Question: VS 2015 shortcut for "GoTo Region" #region / #endregion

Scott Solmer
  • 3,871
  • 6
  • 44
  • 72
  • What language? C#? Different languages have different menu features in VS without the use of plugins. For example, C# has built in refactoring and C++ does not. – jmstoker Sep 16 '13 at 20:54
  • I'm trying to understand your problem. So are you trying to jump to a region by name or just quickly cycle through them? Have you tried `Ctrl + ]`? – jmstoker Sep 16 '13 at 21:00
  • Preferably, I would like to see a list of regions (jump to by name). However cycling though them would be an improvement over using find or scrolling. Ctrl + ] doesn't seem to be hot keyed to anything for me. – Scott Solmer Sep 16 '13 at 21:13
  • No, `Ctrl + ]` won't work for your issue. I misunderstood. That hot key finds matching brackets. – jmstoker Sep 16 '13 at 21:16
  • 1
    Do you have all your code wrapped in #regions? What I mean is if you collapsed your outlining `to definition` do you just see just regions? – jmstoker Sep 16 '13 at 21:23
  • Hey that's pretty good. Ctrl-M + O collapses everything down to my regions! Ctrl-M + P brings everything back. Still requires more effort that I'l like but it seems like this is about as good as it's going to get. – Scott Solmer Sep 16 '13 at 21:35
  • Yeah, it's not ideal, but helps. I've posted it as a solution. – jmstoker Sep 16 '13 at 21:41

3 Answers3

19

Depending on how your code is wrapped in #regions you can use the built-in feature to Collapse to Definition Ctrl + M , O. Then navigate to the region you want. You can undo the collapse by using Ctrl + M , P

jmstoker
  • 3,315
  • 22
  • 36
3

You can create bookmarks in Visual Studio 2010. Nice article here - http://www.codeproject.com/Articles/42973/Using-Bookmark-in-Visual-Studio

  • 1
    Good idea! Create bookmarks for each of your region and name your bookmark the name of your region. Then you can open the Bookmark Window (View menu) and dock it on your IDE on right or bottom of your screen, what fit best for you. You can now navigate real quick. – Matt Roy Feb 07 '19 at 20:55
  • Bookmarks are supposed to be temporary constructs, so are not good for this. – John Stock Jul 23 '19 at 15:03
1

You can try the extension CodeNav that let you see also the code regions on the left pane.

Filippo Bottega
  • 109
  • 1
  • 6