VsCode: 如何避免为每个编辑组打开多个文件?

VsCode: how to avoid to open more than one file for each editor group?

为了提高我的工作效率,我希望能够为每个编辑组只打开一个文件。 我的目的是避免每天打开 20 个或更多选项卡,避免浪费时间在该列表中搜索正确打开的文件。

我想聚焦所需的编辑器组 (CMD + 1, 2, 3, 4) 并打开一个新文件 (CMD + p)。如果在选定的编辑器组中打开一个文件,我希望能够保存它并用新文件替换它。

我认为同时打开最多 4 个文件是完美的,这迫使我更加专注于代码,而不是在一个非常大的打开选项卡列表中搜索文件。

如果您希望限制打开的选项卡的数量,或者根据工作区中打开的选项卡的阈值自动关闭选项卡。

Zen Tabs 插件可能是解决方案。

您的要求:

  • 选项卡通常会在没有任何通知的情况下静默关闭
  • 从设置中可以看出,阈值通常是固定的,但我喜欢动态更改它以防止滚动的想法。

Zen Tabs 是您要查找的扩展程序。

您可以获得更多信息here

If you wish to restrict the number of opened tabs, or close tabs automatically depending upon the threshold of an opened tab in the workspace

不再需要插件:下一个 VSCode 1.42(2020 年第一季度)将为 limiting the number of open editors

提供新设置

有新的设置来限制一次打开的最大编辑器数量。

  • workbench.editor.limit.enabled: Enable this feature (off by default).
  • workbench.editor.limit.perEditorGroup: Whether to apply the limit per editor group or across all groups.
  • workbench.editor.limit.value: The maximum number of open editors (10 by default).

If enabled, VS Code will close the least recently used editor when you open a new editor.

Below you can see the behavior when the limit is set to 3:


by Timo: see "User Interface/ Editor Groups 中所述。


VSCode 1.67(2022 年 4 月)将提出

workbench.editor.limit.excludeDirty

Controls if the maximum number of opened editors should exclude dirty editors for counting towards the configured limit.

参见 issue 144309 and PR 144545