Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

To be more productive on my work, I'd like to have the possibility to open only one file for each editor group. My purpose is to avoid to have 20 or more tabs opened at the and of the day and lost time searching for the right opened file in that list.

I'd like to focus the desired editor group (CMD + 1, 2, 3, 4) and open a new file (CMD + p). If a file is opened in the selected editor group, I'd like to have the possibility to save it and replace it with the new one.

I think that to have at most 4 file opened at the same time is perfect and this forces me to be more focused on the code, instead of search for a file in a very big list of opened tabs.

like image 608
SergioP Avatar asked Sep 28 '18 07:09

SergioP


2 Answers

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

No more plugin needed: the next VSCode 1.42 (Q1 2020) will have a new setting for limiting the number of open editors

There are new settings to limit the maximum number of editors that are open at the one time.

  • 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:

https://media.githubusercontent.com/media/microsoft/vscode-docs/vnext/release-notes/images/1_42/editor-limit.gif


As noted in the comments by Timo: see "User Interface/ Editor Groups".


VSCode 1.67 (Apr. 2022) will propose

workbench.editor.limit.excludeDirty

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

See issue 144309 and PR 144545.

like image 89
VonC Avatar answered Oct 19 '22 03:10

VonC


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.

Zen Tabs plugin might be the solution.

Your requirements :

  • The tabs usually close silently without any notification
  • The threshold, as you can see from the settings, is usually fixed, but I like the idea of changing it dynamically with the intent to prevent scrolling.

Zen Tabs is the extension you are looking for.

restict tabs

You can get additional info here.

like image 1
handlerFive Avatar answered Oct 19 '22 04:10

handlerFive