当我搜索新文件时,VisualStudio 代码会关闭我的文件

我使用 VisualStudio 代码进行工作,并使用 ctrl-P命令在我的目录中搜索文件。

当我要搜索另一个文件时,问题出现了,它在第一个搜索文件的位置打开它,然后关闭它。

有什么设置可以避免这种痛苦吗?

21977 次浏览

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

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.

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