Navigating around in the VS.NET IDE

Last week, Bill Wagner and I were providing some C# training for one of our clients.  Bill showed the class how to use F12 to jump to the definition of a method.  One of the students asked how to go back to your previous position and Bill didn't know the key binding off hand.

As someone who comes from a VB6 background, I've maintained my VB6 keyboard mappings since I moved to C# in 2003.  Navigating around inside the VS.NET IDE has been a no-brainer for me since all of the keystrokes I used for the 7 or 8 years of VB development are the same in VS.NET -- assuming you use the VB6 keyboard layout.

I decided to see if C# has a default key binding to jump back to your previous positions after jumping to a method definition using F12.  First off, I wanted to see what IDE command is mapped to my "go back" function.  I pulled up the VS.NET IDE keyboard options, clicked on the "Press shortcut keys" texbox and hit the keyboard keystroke I use for jumping back to my previous position (Ctrl+Shift+F2):

 image

Looking in the "Shortcut currently used by" field, I see "View.NavigateBackward" is the command used in the IDE to navigate back to your previous position.  Now I changed my keyboard mapping scheme to C# and entered "View.NavigateBackward" into the "Show commands containing" field:

image

So I see control and "-" (minus) is the keystroke to jump back in C#.  I changed my IDE settings to use C# and tested this out.  Sure enough, I can use F12 to jump to a method definition and then ctrl+- to return to my previous position -- sort of like having my own little callstack within the IDE.  :)

And now I've changed my settings back to VB6 mapping scheme since I'm a creature of habit!

1 Comment

  • For years, I've used Shift+F2 to "go to definition" and Ctrl+Shift+F2 to get back. I've done this for so many years that it was a primary habit... When I went to VS 2008 beta, Ctrl+Shift+F2 didn't work even with VB settings. I searched around and finally found the Ctrl+- (minus) shortcut. This worked in VS 2005 and the 2008 beta. I've gotten so used to using Ctrl+- now that I almost didn't notice that Ctrl+Shift+F2 is working in VS 2008 RTM...

    Old habits die hard...

Comments have been disabled for this content.