My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Prevent opening of files over existing tabs in VS Code

Brijesh Shah's photo
Brijesh Shah
·Sep 7, 2020·

2 min read

Introduction

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.

Alt Text

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.

Alt Text

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 :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.

Alt Text

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

Alt Text

  • Uncheck Workbench › Editor: Enable Preview and Workbench › Editor: Enable Preview From Quick Open