129

I can jump to code if I click in a method name and hit F12. But, is there a keyboard short cut to jump back to the previous code editor location?

James
  • 2,586
  • 3
  • 20
  • 32
  • 2
    In Visual Studio Code You can also choose + to return to your original location after navigating using F12. – David Aug 01 '18 at 02:53
  • No. that doesn't work in VS2015. Typical of MS to REMOVE useful and productive features. (It as ALWAYS been Ctrl-* gojng back decades... until those clowns decided to re-write it yet again) – SpacemanScott Apr 10 '19 at 13:06

4 Answers4

207

Ctrl + - : (that's Ctrl and Minus) will navigate back (maps to View.NavigateBackward).

See this list of pre-defined keyboard shortcuts on MSDN.

Johan
  • 71,222
  • 23
  • 174
  • 298
Oded
  • 463,167
  • 92
  • 837
  • 979
  • Thanks a bunch. Such a useful shortcut! – Lou Jan 04 '16 at 21:51
  • 1
    Note: use the minus key with the underscore character. The minus key, on the keypad, may not work for this shortcut. I suppose it depends on the keyboard that you use. – Jesus Is Coming Aug 17 '20 at 13:48
22

@Oded is correct, but wait, there's more!

  • If F12 sent you to a new tab window you can Ctrl + Tab to get back to your original tab. If you hold down Ctrl you can cycle through tab windows
  • In VS 2010 you can Ctrl + Click to Go To Definition, in addition to F12.
  • You can also hold down Ctrl and move your mouse over identifiers to highlight which ones you can jump to
BClaydon
  • 1,732
  • 2
  • 16
  • 32
  • For F12, MSVS 2010 opens a new tab. For MSVS 2013 it replaces current tab. I'm not seeing anywhere to configure this behavior. – crokusek Feb 24 '15 at 19:47
  • To Prevent Closing [Link](http://stackoverflow.com/questions/12795944/how-do-you-prevent-visual-studio-2012-from-automatically-closing-preview-files) – crokusek Feb 27 '15 at 00:47
9

While Ctrl- and CtrlShift- are indeed the shortcuts to navigate to the previous/next cursor position, in this particular case (i.e., going back after F12 or similar) this shortcut might be more useful:

CtrlShift8 (=View.PopBrowseContext)

It will jump back to the place where you pressed F12, ignoring any cursor locations after you pressed F12.

(NOTE: currently using VS 2013, and hoping this shortcut entry also exists in VS 2010...)

Wolfram
  • 420
  • 1
  • 5
  • 10
  • 1
    It existed in VS 2010, and is what I've always used, but it doesn't seem functional in VS 2015, unfortunately. – P Daddy May 16 '16 at 14:58
  • Thanks bro, this is really useful! Seems to work fine on VS2017 CE. – Gam Jul 08 '17 at 01:27
  • 1
    Related: [Visual Studio 2015: Ctrl+Shift+8 (View.PopBrowseContext) to navigate back not working?](https://stackoverflow.com/q/32097787/3258851) – Marc.2377 Dec 17 '18 at 13:00
3

In Visual Studio Code, you can also use Alt + Left-Arrow to return to your original location in the source code after navigating with F12.

David
  • 411
  • 4
  • 13