Reputation: 2121
--- edit
Let's say that I have the following scenario in vscode:
I have 3 open files, with vscode showing two files at once.
on the left I have 2 tabs: a.js
, in foreground, with
import { b } from './b';
import { c } from './c';
b();
c();
and b.js
, with
export function b() {
// ...
}
and on the right I have c.js
, with
export function c() {
// ...
}
My goal is:
starting from a.js
as current focused editor
to have a shortcut - ideally ctrl-click - that
b()
takes the tab with b.js
in foreground and focuses on the function b() {
definitionc()
, move the focus on the right side, with c.js
in foreground, and focuses on the function c() {
definition.keep in mind that I DO NOT want to use different shortcuts. This is a simplified example (normally I have multiple tabs AND multiple columns opened) but normally I don't know where the target is, and definitely I don't want the same file opened multiple times.
Is there a way to get it?
--- original
In vscode, according to https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition
You can jump to the definition with Ctrl+Click or open the definition to the side with Ctrl+Alt+Click.
Now, I use the side panel a lot, and sometimes the "target" where the definition is, is in another side, and sometimes is a different tab in the same side on where I am now.
If I do the appropriate choice I can go directly to the already opened buffer. If I choose the "wrong" shortcut a new buffer of the same file is opened.
Is there a way to make the "go to definition" smart? I just want to always go to the already opened file (if is available).
Upvotes: 5
Views: 3842
Reputation: 2818
You should head to VS Code's settings and select the Reveal If Open
option.
You'll be able to find it in the Workbench --> Editor Management
section.
Upvotes: 7