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

7
  • 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, 2013 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, 2013 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. Sep 16, 2013 at 21:13
  • No, Ctrl + ] won't work for your issue. I misunderstood. That hot key finds matching brackets.
    – jmstoker
    Sep 16, 2013 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, 2013 at 21:23

3 Answers 3

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

3

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

2
  • 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 7, 2019 at 20:55
  • Bookmarks are supposed to be temporary constructs, so are not good for this.
    – John Stock
    Jul 23, 2019 at 15:03
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.