How to prevent VS Code from replacing an already opened preview tab with a subsequently opened one?

In visual studio code, by default, when you click on a file from the Explorer panel, the file will open in a preview tab. If you do not make any changes to this file and click another file, the second file will open in the same preview tab replacing the first file. This may not be convenient for everyone. So, let’s see how to prevent VS Code from replacing an already opened preview tab with a subsequently opened one?

The below solutions are tried and tested on Visual Studio Code version 1.87.

By double-clicking the file

The file will be opened in the preview tab only if you single-click the file name from the Explorer panel. If you double-click the file name, the file will open in the regular tab and won’t get closed when you click on another file.

By double-clicking the tab

Another option is to double-click the preview tab once the file is opened. Once the preview tab is double-clicked, it will be converted to a regular tab (you can see the file name on the tab changes from italic font style to regular font) and won’t get closed when you click on another file.

“Keep Open” option

Another option is to right-click the tab and select the Keep Open option from the context menu. Once selected, the preview tab will be converted to a regular tab.

Disabling the preview mode

Still if you feel that you don’t need the preview mode, then you can disable the option in the settings. Follow these steps to disable the preview mode:

  1. Use the keyboard shortcut Ctrl+Shift+P to launch the command palette.
  2. In the command palette, enter Preferences: Open User Settings to open the user settings.
  3. In the user settings, go to Workbench >> Editor management.
  4. Disable the the below options:
    • Enable Preview
    • Enable Preview From Quick Open
prevent VS Code from replacing an already opened preview tab with a subsequently opened one

Reference


Leave your thoughts...

This site uses Akismet to reduce spam. Learn how your comment data is processed.