How to navigate back to the last cursor position in Visual Studio?

Visual StudioNavigationKeyboard Shortcuts

Visual Studio Problem Overview


What is the keyboard shortcut navigate back to the last cursor position in Visual Studio?

Visual Studio Solutions


Solution 1 - Visual Studio

Visual Studio 'Navigate Back' shortcut

It Will not work for red color (-) key. For me it only works for blue color combination.

Solution 2 - Visual Studio

According to Visual C# 2008 Keybinding Reference Poster it is Ctrl + -. The name of the specific keybinding is View.NavigateBackward.

PS: While researching I also found that Ctrl + . is the same as Shift + Alt + F10. Nice!

Solution 3 - Visual Studio

ctrl + - (dash) navigates backward.

ctrl + shift + - (dash) navigates forward.


These settings can be found under Environment -> Keyboard:

enter image description here

Solution 4 - Visual Studio

For Changing the setting in Visual Studio 2019:

enter image description here

  1. Search for view.navigate
  2. CHOOSE "Text Editor" from the "Use new shortcut in:" drop down menu
  3. Select your shortcut

Global doesn't catch for this.

Solution 5 - Visual Studio

For new VS Code(1.28.2)

Back: Ctrl+Alt+- (dash)

Forward: Ctrl+Shift+- (dash)

Solution 6 - Visual Studio

The most generic answers is: there is no working default and you need to define your own keyboard shortcuts for View.NavigateBackward and View.NavigateForward.

Why? For most keyboards, the default shortcut is a broken, unusuable combination because VS badly handles the shift and altGr modifiers. MS did not pay attention to portability and internationalisation so much when they redeveloped VS after version 6, and this is still true today. This bug has been there for way more than a decade, nearly two decades. At this rate, it will never be fixed. And yes, I have filled a bug report, and I'm certainly not the only one.

However, their "VSCode" product line does have better keyboard handling as it doesn't depend on the shift or altGr modifiers to identify the key. For example, when you are in text writing mode and press the key that has the dash symbol, without using shift nor altGr, let's say it writes something else, like number 6. To VSCode when it comes to shortcut handling, that's still the dash key for its purpose. As long as a key has the symbol written on it, whether this is painted as the 1st, 2nd or 3rd level doesn't matter, it just that key.

Of course, it's never a good thing to make the default shortcuts use non-alphanumeric symbols, that's always confusing, whether it works or not. The good mature text editors have known that for a long time and should be taken as examples of things done right. In some ways, VS learned a few good things from emacs with shortcuts that are a sequence of two letters, but ultimately screwed up on other parts with the choice of non-alphanumeric bindings, combined with a broken low-level keyboard handling.

Solution 7 - Visual Studio

This works for me in Visual Code

Navigate backward Alt+

Navigate forward Alt+

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJader DiasView Question on Stackoverflow
Solution 1 - Visual StudioPrageeth godageView Answer on Stackoverflow
Solution 2 - Visual StudioJader DiasView Answer on Stackoverflow
Solution 3 - Visual StudioJim AhoView Answer on Stackoverflow
Solution 4 - Visual StudioGulzarView Answer on Stackoverflow
Solution 5 - Visual StudioAbhijith SView Answer on Stackoverflow
Solution 6 - Visual StudioJohan BouléView Answer on Stackoverflow
Solution 7 - Visual StudioManjuView Answer on Stackoverflow