How to prevent VS Code from opening multiple instances of a same file?

Solution 1:

By default, VS Code will open a new Editor with the desired file. If you'd like to instead reveal the already open Editor, set workbench.editor.revealIfOpen to true in your User Settings (CMD+k on OSX).

To be concrete, that means adding the following line:

"workbench.editor.revealIfOpen": true,

See Also: Visual studio Code - prevent same file opening twice

Solution 2:

This worked for me:

  "window.openFilesInNewWindow": "off",
  "window.openFoldersInNewWindow": "off",
  "security.workspace.trust.untrustedFiles": "prompt"