A quick note on how to return to your original cursor position after jumping to a code definition with F12 (Go to Definition) in VSCode.
Introduction
F12 (Go to Definition) in VSCode is useful when reading through code.
However, I couldn't immediately figure out the shortcut to go back to where my cursor was before the jump, so I'm jotting this down for future reference.
Note: This article was translated from my original post.
Shortcut to Go Back in VSCode
The default shortcuts for each OS are as follows:
| OS | Shortcut |
|---|---|
| mac | Ctrl - |
| win | Alt ← |
| linux | Ctrl Alt - |
You can find this documented in the official VSCode docs here:
Keyboard shortcuts for Visual Studio Code

You can also assign a custom shortcut using the command ID workbench.action.navigateBack.
Conclusion
That's a quick note on how to go back to your previous location after using F12 in VSCode.
Hope this helps someone out there!
[Related Articles]
References
- Keyboard shortcuts for Visual Studio Code
- https://github.com/microsoft/vscode-docs/blob/main/docs/getstarted/keybindings.md
- vscode-docs/build/keybindings/doc.keybindings.osx.json at main · microsoft/vscode-docs · GitHub
- vscode-docs/build/keybindings/doc.keybindings.win.json at main · microsoft/vscode-docs · GitHub
- vscode-docs/build/keybindings/doc.keybindings.linux.json at main · microsoft/vscode-docs · GitHub
- Visual Studio Code tips and tricks