Prevent opening of files over existing tabs in VS Code


Visual Studio Code is an awesome lightweight code editor as we all know it. However, many of us have gone through the situation where when you click or open a file, it opens in one of the existing tabs, replacing the previous file. At a certain point in time, you will get annoyed enough to search through the web looking for an explanation for the same and a way to stop it. Well, look no further.

The Reasoning and Solution

On a closer look, you can notice that the tab which gets replaced has the tab name in italics.

That indicates that it is a preview of the file. As there can only be one preview tab, the preview will change if you select another file. This is intentional and delivered by VS Code as a feature to prevent you from opening several tabs when you are just looking around for a particular file.

One way to resolve this is by double-clicking on that tab. This will remove the file from the preview state and stick it on the panel.

I know your next question will be, "But what if I don't want to move my hands from the keyboard? There has got to be a shortcut.". And there is.

  • Select the preview tab
  • Press Command + K (Ctrl + K for Windows) and then hit Enter

You're welcome emoji-smile

Finally, what if one wants to open the files in a new tab every time irrespective of whether they are opened from Explorer on the side or Quick Open.

vs code quick open

  • Open VS Code Settings
  • Search for “enable preview”

vs code disable preview feature

  • Uncheck Workbench › Editor: Enable Preview and Workbench › Editor: Enable Preview From Quick Open
© 2021 Brijesh Shah, Built with Gatsby