Go to definition and back to reference in visual Studio Code

I'm currently using VSCode and am trying to use the F12 shortcut which takes me to a definition of an object/function. When I want to go back to the reference, I can't seem to find the right way to do it. With VS community I used Shift + F12.

I've try different combinations, such as Alt + F12 or Shift + F12 but all I get is a peek definition of the element which is not useful at all; it's just a popup showing the same element in the same file I'm at. I've seen answers to this question but pertaining to VS 2010 which are no longer applicable or doesn't work with VSCode.

Question: What is the shortcut to Go Back once you've used F12 to Go to the definition?


Solution 1:

For macOS it is ⌃- (Ctrl + -) by default. And for Windows: (Alt + LeftArrow)

Solution 2:

According to the vscode keyboard shortcuts documentation page, the navigateBack action defaults to Ctrl+Alt+-.

In my keybindings.json file, I've rebound it to ctrl+- using:

{ "key": "ctrl+-", "command": "workbench.action.navigateBack" }