How can I navigate back to the last cursor position in Visual Studio Code?
Solution 1:
The keyboard shortcut commands are Go Forward and Go Back.
On Windows:
Alt + ← ... navigate back
Alt + → ... navigate forward
On Mac:
Ctrl + - ... navigate back
Ctrl + Shift + - ... navigate forward
On Ubuntu Linux:
Ctrl + Alt + - .., navigate back
Ctrl + Shift + - ... navigate forward
Solution 2:
I am on Mac OS X, so I can't answer for Windows users:
I added a custom keymap entry and set it to Ctrl + ← + Ctrl + →, while the original default is Ctrl + - and Ctrl + Shift + - (which translates to Ctrl + ß and Ctrl + Shift+ß on my German keyboard).
One can simply modify it in the user keymap settings:
{ "key": "ctrl+left", "command": "workbench.action.navigateBack" },
{ "key": "ctrl+right", "command": "workbench.action.navigateForward" }
For the accepted answer I actually wonder :) Alt + ← / Alt + → jumps wordwise for me (which is kind of standard in all editors). Did they really do this mapping for the Windows version?
Solution 3:
This will be different for each OS, based on the information in Key Bindings for Visual Studio Code.
Workbench configuration:
Go Back: workbench.action.navigateBack
Go Forward: workbench.action.navigateForward
Linux:
Go Back: Ctrl+Alt+-
Go Forward: Ctrl+Shift+-
Mac OS X:
Go Back: Ctrl + -
Go Forward: Ctrl + Shift (⇧) + -
Windows:
Go Back: Alt + ⬅️
Go Forward: Alt + ➡️