I have VS Code 1.38.0.

I'm programming in C and I like working with files open side by side. Let's say I have a file "L" open on the left side and a file "R" open on the right side. If there is a function call in file L that is defined in file R, if I right-click on the function call and select "Go to Definition", a new tab with the file R will open on the left side and now I have file R open twice. What i want instead is for the already open file R to just go to the definition of the function. Is there any setting to enable that?

This behavior actually works when you have left panel only and multiple tabs but doesn't work if you have both left and right panel open.

  • 2
    Do the two opened instances have absolutely identical total paths, or do they differ on anything (even lower/upper-case)?
    – harrymc
    Sep 6 '19 at 13:51
  • Yes. I will right-click on a function in file A and select "Go to declaration". This will open the file where the function was declared. I will then drag that file on the right panel. Now if I right-click and Go to declaration on the same function on file A, it will open a new tab on the Left with the same file that is also on the Right
    – stefanos
    Sep 9 '19 at 6:45
  • You might get better answers on Github VScode.
    – harrymc
    Sep 9 '19 at 7:19
  • Alright, thank you. I'll give it a try :)
    – stefanos
    Sep 10 '19 at 8:04
  • 1
    The answer is to add this to your settings.json: "workbench.editor.revealIfOpen": true Feb 6 '20 at 17:05
"workbench.editor.revealIfOpen": true

This should do the work. It's a Setting in VSCode

  • Why? How? Please explain.
    – peterh
    Apr 16 '20 at 10:46
  • 2
    File > Preferences > Settings > (Workbench > Editor: Reveal If Open) Apr 6 '21 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.