What is the keyboard shortcut navigate back to the last cursor position in Visual Studio Code?
I am on Mac OSX, 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 kinda standard in all editors). Did they really do this mapping for the windows version?
With VSCode 1.43 (Q1 2020), those Alt+← / Alt+→, or Ctrl+- / Ctrl+Shift+- will also... preserve selection.
See issue 89699:
Benjamin Pasero (bpasero) adds:
going back/forward restores selections as they were.
Note that in order to get a history entry there needs to be at least 10 lines between the positions to consider the entry as new entry.
⌘+U Undo last cursor operation
You can also try ctrl+-
BTW all the shortcuts is here https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf This is really useful!
Mac OS (MacBook Pro):
Back: CTRL(control) + - (Hyphen)
Back Forward: CTRL + Shift + - (Hyphen)