TIL: Fixing VSCode File Opening Behavior (Preview Mode)


Today I Learned why VSCode was replacing the currently open file in the editor every time I clicked on a new one in the sidebar. It was due to the preview mode being enabled.
In preview mode, VSCode opens files temporarily to save editor space. The tab shows the filename in italics, and opening another file replaces it unless you double-click the tab or file name to make it permanent.
To make every file open in a new tab by default, I disabled preview mode globally by adding this to settings.json
:
Open Command Palette (Ctrl+Shift+P)
Search for “Preferences: Open User Settings“
Add
"workbench.editor.enablePreview": false
insettings.json
file
settings.json file:
Now, files always open in new tabs. Super helpful for side-by-side comparisons or quick multitasking.
Heads-up:
Disabling preview mode might lead to more open tabs. If you prefer a cleaner workspace, keeping preview mode on and using double-click when needed might be a better fit.
Reference:
Subscribe to my newsletter
Read articles from JayRam Nai directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

JayRam Nai
JayRam Nai
Open edX expert and open-source enthusiast.