转到定义并返回到可视化 Studio 代码中的引用

我目前正在使用 VSCode,并尝试使用 F12快捷方式,它将我带到一个对象/函数的定义。当我想回到参考文献时,我似乎找不到正确的方法。在 VS 社区中,我使用了 Shift + F12

我尝试过不同的组合,比如 Alt + F12或者 Shift + F12,但是我所得到的只是元素的一个小小的定义,这个定义一点用都没有; 它只是一个弹出窗口,显示我所在的同一个文件中的同一个元素。我已经看到了这个问题的答案,但涉及到 VS2010不再适用或不与 VSCode 工作。

问题 : 使用 F12转到定义后,返回的快捷方式是什么?

107001 次浏览

Shift + F12 should be working for you. There is a box on the right of the peek view which lists all the references. You are seeing the peek view to the reference you went to (the definition) but on the right are more. That boundary between the two can be dragged left and right so perhaps yours is not visible - trying dragging the peek view box right boundary to the left after you hit Shift+F12. Do you see a list of references there? Double-clicking the one you started from originally will take you back to it.

Edit:

v1.29 added some nice functionality for listing the references in the sidebar. See references view.

List All References in the context menu or Shift+Alt+F12

Results are stable and individual results can be cleared, which is great if you use the view as a To Do list. You can use F4 and Shift+F4 to navigate through results without taking your hands off the keyboard.

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" }

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

You can open the Keyboard Shortcuts to find the shortcuts.

Preferences > Keyboard Shortcuts

Search for Go, and it’ll show the Go Back and Go Forward shortcuts.

In macOS:

Go Back: ⌃- (Ctrl+-)

Go Forward: ⌃⇧- (Ctrl+shift+-)

[
{
"command": "workbench.action.navigateBack",
"key": "ctrl+-"
},
{
"command": "workbench.action.navigateForward",
"key": "ctrl+shift+-"
}
]

An alternative approach is to use the Ctrl+Alt+Click shortcut, which will open the definition in a new pane to the right. This can then be closed with the usual Ctrl+F4 key combination.

Alt + Left arrow worked for me or Go menu and then Back.

Go to definition F12

Back to declaration Ctrl + F12

Try goto-symbol-stack.

This extension implements a stack tracking the positions only when the goto-definition is triggered by Alt+], and allows the user go back to the reference using Alt+[. No annoying cursor movement in the stock navigation(Alt+).

For those using the VSCodeVim extension, it would be Ctrl + o and Ctrl + i

ALT + Left Arrow and ALT + Right Arrow worked for me. VS code listed all shortcuts in pdf keyboard-shortcuts-windows.pdf. To see all keyboard shortcuts go to menu bar Help->Keyboard Shortcuts Reference. It will open pdf that contains all shortcuts.enter image description here

I have a similar problem. Fix it by installing this JDK 8 to VSCode

1.Go Definition - F12 or Right click and Click Go to Definition Option

2.Back to Reference - Alt + Left Arrow

Next : Ctrl + F12

Back : Alt + LeftRow (<--)

For Windows is working.

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

ref

In Version: 1.62.3 under Ubuntu:
it's just F12 again

it's bound to both:

  • Go to Definition
    and
  • goToNextReference