Visual Studio Code closes my file when I search for new ones

EditorVisual Studio-CodeText Editor

Editor Problem Overview


I'm using Visual Studio Code for working and I use ctrl-P command to search for files in my directory.

The problem appears when I want to search for another file, it opens it in the place of the first searched file, closing it.

Is any setting for avoiding this pain?

Editor Solutions


Solution 1 - Editor

By default, VSCode opens files in preview mode. This is indicated by their name being italic in the menu bar. As John noted, you can double click on the file to fully open it.

To disable this behavior, try setting:

"workbench.editor.enablePreview": false

Solution 2 - Editor

When you select a file from search result -> you will see the file open with file name italicized. This means that the file is open in preview mode. Now any other file you choose to select will replace its content in this tab.

To make this tab stick among the open tabs you can:

double click to select the file or double click on already selected file in search pane -> you will see the name of file is not italicized anymore(meaning the file is now pinned as a tab)

Alternatively,

You can use the below setting to have all selected files open as a separate tab: > "workbench.editor.enablePreview": false

This setting is found here : Files -> Preferences-> Settings

But the downside of using this is that all files you click on will remain opened and you would then need to clean tabs after your search.

Solution 3 - Editor

Ctrl+P -- For targetting a file Alt+Enter -- For Opening that file into next tab

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSamurai JackView Question on Stackoverflow
Solution 1 - EditorMatt BiernerView Answer on Stackoverflow
Solution 2 - EditorSameeksha KumariView Answer on Stackoverflow
Solution 3 - EditorSohail AsgharView Answer on Stackoverflow