始终在新标签页中打开文件

本文翻译自:Open files always in a new tab

I am using Visual Studio Code 1.3.1 with the newly introduced tabs. 我正在使用带有新引入的选项卡的Visual Studio Code 1.3.1。

When I click on files, the first file will open in a tab. 当我单击文件时,第一个文件将在选项卡中打开。 If I do not make any changes to this file, the second clicked file will open in the same tab. 如果我未对此文件进行任何更改,则第二个单击的文件将在同一选项卡中打开。

How can I avoid this and make Visual Studio Code always open a new tab? 如何避免这种情况并使Visual Studio Code始终打开新选项卡?


#1楼

参考:https://stackoom.com/question/2cR7l/始终在新标签页中打开文件


#2楼

When you [single-]click a file in the left sidebar's file browser or open it from the quick open menu ( Ctrl - P , type the file name, Enter ), Visual Studio Code opens it in what's called "Preview Mode", which allows you to quickly view files. 当您在左侧工具栏的文件浏览器中单击[单个]或从快速打开菜单( Ctrl - P ,键入文件名, Enter )中打开文件时,Visual Studio Code将以所谓的“预览模式”将其打开。使您可以快速查看文件。

Preview Mode tabs are not kept open. 预览模式选项卡不会保持打开状态。 As soon as you go to open another file from the sidebar, the existing Preview Mode tab (if one exists) is used. 一旦您从侧栏中打开另一个文件,就会使用现有的“预览模式”选项卡(如果存在)。 You can determine if a tab is in Preview Mode, by looking at its title in the tab bar. 您可以通过查看选项卡栏中的标题来确定该选项卡是否处于“预览模式”。 If the title is italic , the tab is in preview mode. 如果标题为斜体 ,则选项卡处于预览模式。

To open a file for editing (ie don't open in Preview Mode), double-click on the file in the sidebar, or single-click it in the sidebar then double click the title of its Preview Mode tab. 要打开文件进行编辑(即不在预览模式下打开),请双击侧边栏中的文件,或在侧边栏中单击该文件,然后双击其“预览模式”选项卡的标题。

If you want to disable Preview Mode all together, you can do so by setting "workbench.editor.enablePreview": false in your settings file. 如果要一起禁用预览模式,可以通过在设置文件中设置"workbench.editor.enablePreview": false来禁用。 You can also use the "workbench.editor.enablePreviewFromQuickOpen" option to disable it only from the quick open menu. 您也可以使用"workbench.editor.enablePreviewFromQuickOpen"选项仅从快速打开菜单中将其禁用。

Before you can disable Preview Mode, you'll need to open your Settings File . 必须先打开“设置文件” ,然后才能禁用“预览模式

Pro Tip : You can use the Command Palette to open your settings file, just enter " Preferences: Open User Settings "! 专业提示 :您可以使用命令面板打开设置文件,只需输入“ Preferences: Open User Settings ”!

Once you've opened your settings file ( your settings file should be located on the right), add the "workbench.editor.enablePreview" property, and set its value to false . 一旦你打开你的设置文件( 设置文件应位于右侧),添加"workbench.editor.enablePreview"属性,其值设置为false

You can learn more about Visual Studio Code's "Preview Mode", here . 您可以在此处了解有关Visual Studio Code的“预览模式”的更多信息。


#3楼

If you don't want to disable preview mode you can explicitly tell vscode to keep a specific tab open. 如果您不想禁用预览模式 ,则可以明确告诉vscode保持特定选项卡处于打开状态。 As mentioned above a tab heading with italic text is in preview mode . 如上所述,带有斜体文本的选项卡标题处于预览模式

To get a tab out of preview mode you can either right click on the tab and choose keep open or use the shortcut cmd + k enter that is mapped to the command workbench.action.keepEditor 要使选项卡脱离预览模式 ,可以右键单击该选项卡并选择keep open或使用快捷方式cmd + k enter映射到命令workbench.action.keepEditor


#4楼

我提出了同样的问题,并打开setting.json文件,添加以下内容:

"workbench.editor.enablePreview": false

#5楼

Watch for filename in italic 注意斜体文件名

Note that, the file name on the tab is formatted in italic if it has been opened in Preview Mode . 请注意,如果已在“ Preview Mode打开,则选项卡上的文件名将以斜体格式显示

Quickly take a file out of Preview Mode 快速从预览模式中取出文件

To keep the file always available in VSCode editor (that is, to take it out of Preview Mode into normal mode), you can double-click on the tab. 要使文件在VSCode编辑器中始终可用(即,使它从“ Preview Mode进入正常模式),可以双击选项卡。 Then, you will notice the name becomes non-italic. 然后,您会注意到名称变为非斜体。

Feature or bug? 功能或错误?

I believe Preview Mode is helpful especially when you have limited screen space and need to check many files. 我认为“预览模式”特别有用,特别是在屏幕空间有限且需要检查许多文件的情况下。


#6楼

Use workbench.editor.enablePreview: false to disable Preview mode completely. 使用workbench.editor.enablePreview: false可以完全禁用预览模式。

Use workbench.editor.enablePreviewFromQuickOpen: false to disable Preview mode for the files open from quick open menu. 使用workbench.editor.enablePreviewFromQuickOpen: false为从快速打开菜单中打开的文件禁用预览模式。

发布了0 篇原创文章 · 获赞 7 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/asdfgh0077/article/details/105306008