Stop Visual Studio Code From Closing the Current File When Clicking a New File to Open It.

The Visual Studio Code Editor’s default behavior of opening files in “preview mode” when clicking the file name in explorer can be frustrating in certain circumstances. I learned how to shut that behavior off today, so thought I would share it here.

How to Disable Preview Mode in Visual Studio Code

  1. Click File > Preferences > Settings

  2. Search for “preview mode” in the Settings search bar:

Search Settings for Preview Mode

Search Settings for Preview Mode

  1. Uncheck the box under “Workbench > Editor: Enable Preview”
Checkbox under Enabled Preview

Uncheck This Checkbox to Shut Off Preview Mode

  1. Visual Studio Code will show a vertical line next to the setting to indicate it has been changed.
Checkbox under Enabled Preview

Uncheck This Checkbox to Shut Off Preview Mode

  1. Close the Settings window

    The setting change will be automatically applied when the window is closed.

Once these instructions have been completed, Visual Studio Code will leave any file you click on open in the Editor window.


The postings on this site are my own and do not necessarily reflect the views of my employer.

The content on this blog is for informational and educational purposes only and represents my personal opinions and experience. While I strive to provide accurate and up-to-date information, I make no guarantees regarding the completeness, reliability, or accuracy of the information provided.

By using this website, you acknowledge that any actions you take based on the information provided here are at your own risk. I am not liable for any losses, damages, or issues arising from the use or misuse of the content on this blog.

Please consult a qualified professional or conduct your own research before implementing any solutions or advice mentioned here.