Vscode: Have a setting for maximum number open files (editors)

Created on 27 Jul 2016  ·  63Comments  ·  Source: microsoft/vscode

I've noticed that there is no way to limit the number of total files open at once. There is an explorer.openEditors.visible option, but that seems to limit the height of the "Open Editors" pane (which I don't use - I use tabs instead).

To keep my workspace focused, I like my editor to automatically close files over a set threshold that I have least recently viewed. Obviously, it wouldn't close files that have unsaved changes (or it would prompt you prior to trying to close them).

Does this sound like a reasonable request? Please let me know!

feature-request on-testplan workbench-editors

Most helpful comment

Any word on this? Zentabs is one of the only things I miss from Atom. (Love VS Code!)

Where would be some relevant parts of the project to take a look at?

All 63 comments

Thanks for the suggestion. I've not seen this behaviour in other editors. I have to admit I'm a bit wary of anything that automatically closes an editor without any intervention from the user. It feels like it could open up a bunch of other UX issues. For example:

  • How does the user know that the file has been closed?
  • Does the threshold change if the size of the window changes (since a different number of tabs would be visible)?
  • Is least recently viewed always the best way to determine which files to close?

For example, I could be on a hunt for something and start with one file open then open a sequence of files when I view definitions and references. Eventually I might reach the thing I am looking for but only after exceeding the threshold. The file I started the search from is very relevant but it would have been the least recently viewed. It doesn't seem right to close it since I would want to go back to it, now that I have found the information I need.

Hi Steven,

Great questions. First of all, I have this behavior in IntelliJ IDEA and Sublime Text (via the Zen Tabs plugin):

screen shot 2016-07-29 at 9 30 17 am

screen shot 2016-07-29 at 9 31 28 am

As for your questions:

  • 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.
  • IDEA lets you choose between "less frequently used" and "non-modified" files. I don't know how Zen Tabs chooses.

I think your concern about navigating through a number of files and then returning to the initial file is valid, but after a certain point, you're going to have to scroll through your tab bar to get back to where you started - and I'd much prefer just re-opening the file with ⌘+P or similar.

Exposing this as an extension seems like the right approach. I'm just not sure if we expose the necessary APIs to enable this.

Any word on this? Zentabs is one of the only things I miss from Atom. (Love VS Code!)

Where would be some relevant parts of the project to take a look at?

Limiting number of the clean editors open is function which has existed in Eclipse for time immortal (or more precisely, as long I've been using it).

The behavior if there are no editors are clean is configurable:

  • Open more editor buffers or
  • Prompt to save & close a buffer.

Actually, this is a good feature, for minimal and productive workflow.

Usually, I limit tabs to only 1 file (and I'm missing this feature in vscode)

  • Whenever I change to a new file then auto-save is enabled to save the old one
  • If I want to reopen the last closed file, use cmd+shift+tab
  • And to switch between recent files, cmd+e recent-files helps for that.

The UX of side scrolling many tabs is worst than disappearing tabs. Just remove the oldest unmodified tab, and with auto saving, this means you can remove the oldest tab.

I think a reasonable default is to auto close tabs if there isn't enough room in the tab bar to add more.

Hi @stevencl, about your comment

Exposing this as an extension seems like the right approach. I'm just not sure if we expose the necessary APIs to enable this.

is there (or will be) in the API anything to close a tab/file?

Thank you very much in advance 💯

@jrieken / @bpasero - is there any API or setting that would support this, now or in the future?

Yeah, see #15178 for exposing the tab-model to extensions

Thank you very much @stevencl and @jrieken 🥇

So looking forward to this feature. I miss ZenTabs so much 😅

+1 for this feature. I also miss ZenTabs from Sublime!

I've just found out that something similar can be achieved simply by setting workbench.editor.showTabs to false.

Together with workbench.action.showAllEditors set to ctrl+e it almost feels like intellij and tab limit 1.

@diacone the problem is that the tabs are not closed so when you work with 2 column layout, you cant ensure that a file that you try to reopen opens in the expected column and not in the one where the file open before.

any progress on this, i still miss this from Atom

Any update? This is really annoying to not have this feature. It becomes a mess really quickly on large projects...

This would solve the funky interaction of opening a file, then opening a second file and invoking "recently opened" but the first file is not there to choose since it's still "open".

So +1 for 1 tab limit like intellij/atom/sublime has ! :)

Just to add, Xcode is one tab limited by default—and only opens new tabs through shortcuts (like a browser).

@bpasero please stop closing issues as duplicates of this one. This is not the same issue as https://github.com/Microsoft/vscode/issues/2105 or https://github.com/Microsoft/vscode/issues/10859 or https://github.com/Microsoft/vscode/issues/19230. This issue is about the number of open files, but the issues you marked as duplicates are about the number of panes.

I have a wide monitor and I would like to have more than 3 editor panes open at once. I don't care about open files or tabs.

@nickretallack please start using the GH issue search function and find issues like https://github.com/Microsoft/vscode/issues/14909

That issue has a much larger scope, and it's not the one you marked the other three issues as duplicates of.

Is there some technical reason why we can't have more than three code panes at once? Isn't that an arbitrary number?

+1, need this like the Zentabs plugin.

+1, the current system causes tab overload.

+1 oneeeeeee

+1 thinking of going back to Atom...

Earlier in the thread there was a discussion about this being a great candidate for an extension. Since then, I believe a fair amount of work has been done on the API for open editors. Take a look at https://github.com/Microsoft/vscode/issues/15178 for example.

Regarding the limit of three panes that @nickretallack asked about, the grid layout feature that @bpasero linked to (https://github.com/Microsoft/vscode/issues/14909) removes that limit.

Let us know what else you think needs worked on to enable the experience described by @JeffreyATW.

@stevencl my understanding was that this issue asks about a maximum number of editors per editor group: that means, if you configure this to e.g. 5, you cannot open more than 5 editors (in the same group, not side by side). After that some editors will just be reused (the least recently used, unless maybe all are dirty?). I think Eclipse provides such a setting iirc.

@bpasero, yes, that is my understanding too. There was discussion early in the thread about implementing this via an extension which I think is still probably the appropriate way to enable this functionality.

I think we are lacking some API to do this properly.

@bpasero Following @nickretallack comment:

i don't think that Issues #2105, #10859 and #19230, that you closed as duplicates of this one, are duplicates at all.
As you mentioned this issue "asks about a maximum number of editors per editor group ", while those other issues ask about number of editor groups limited to only three. As you can see in this screenshot, LEFT, CENTER and RIGHT, regardless on the number of editors that each editor group can hold.

image

As you suggested i used GH issue search, and all of them were closed as duplicated, pointing to this issue that doesn't intent to solve the problem.

Thanks for the time.

Have you seen this extension guys?

"workbench.editor.showTabs": false, add this and it works - I meant if you want to keep your workspace focused and only have one tab ;)

Any updates on this?

Still not available? This is driving me crazy. I want to like VS Code, but it seems to be missing vital features that are readily available in Atom and seeing that this has been discussed for over 2.5 years is sort of questionable.

Zen tabs does not work smoothly. It would be really nice to have this feature out of box

I agree^. I tried the package before connecting but it was too jarring to use. I assume it’s the dev having to working around not having proper calls to these things, so it would be great if it were built in.

Ok, so....
I just published an extension called OneTab as a temporary solution to this problem, but I don't see a current good solution from vscode for this.

The current problem:
@msoedov The zentab extension does not work smoothly because what the creator is doing is a very hacky solution. He basically dispatches an action to switch to the oldest editor, then he dispatches an action to close the editor, and finally dispatches an action to switch back to the newest editor. The problem is that when you switch to a different editor, vscode re-centers the Explorer. I'm pretty sure this is the 'not working smoothly' you are referring to. The core of the problem is that we need some action to either close a tab at index or close the oldest tab without actually switching to it. Unfortunately, those don't exist right now.

My Solution: OneTab
My extension OneTab attempts to get us a temporary solution by using the currently available action closeOtherEditors to just close all the other editor when you open a new one. This is the only way I can see from current actions to close editors without switching. Essentially, if you don't mind having just one editor open at a time, this extension should work for you.

@alexjoyner Thx man I will check this out!

Maybe it's time to prioritize this issue. VsCode keeps adding new features (which is great :), but not having an option to limit the number of open tabs/files is unacceptable ; this should be the basics of any code editor. Every 30 minutes I'm getting lost with all my open tabs and have to close them all and start over. This is very unproductive

I couldn’t agree more. We need VS Code for our collaborative coding, but this one issue alone is the biggest deal-breaker.

  1. after hours of work:
    屏幕快照 2019-04-24 下午3 23 22

  2. stop my work && cleanup.

  3. refocus.

  4. goto 1

this is NOT PRODUCTIVE. 🙁

I assume @EAT-CODE-KITE-REPEAT's comments are in jest.

If not, they involve a scope creep which should be their own issue. They should not be covered in this issue.

still no progress???:(((((

stevencl commented on 29 Jul 2016

  • Does the threshold change if the size of the window changes (since a different number of tabs would be visible)?

I wouldn't close tabs based on window width. It would be annoying if a temporary width change closed files, e.g. moving a fullscreen window to a different monitor might suffice (at least when using keyboard shortcuts), I guess.

  • Is least recently viewed always the best way to determine which files to close?

For example, I could be on a hunt for something and start with one file open then open a sequence of files when I view definitions and references. Eventually I might reach the thing I am looking for but only after exceeding the threshold. The file I started the search from is very relevant but it would have been the least recently viewed. It doesn't seem right to close it since I would want to go back to it, now that I have found the information I need.

If closed files stayed in the back navigation list, navigating back to the relevant file (which I'd use anyway in such a situation) should reopen it. (However, a forward / back menu to do multiple steps at once would help.)

https://marketplace.visualstudio.com/items?itemName=hitode909.zentabs

This works pretty well, thanks @williamluke4
However agree with the above that this should be a built-in feature.. so core!

Hi, zentabs is oke, but it keeps opened all the files. is there a way to keep open only the file it is on the current tab or split view? So I have one view, the maximum number of opened files should be 1, if I have a split of two windows, then 2... and show on. My major concern is that is when I close the split view.. it doesn't close it because it starts showing all kind of recent files...

Also zentabs is not the smoothest experience. At least for me, flickering occurs when closing a tab.

Yeah I've uninstalled it

@bpasero Any chance we could get your input here? This has now started to crash my extension host.

Error: EMFILE: too many open files, uv_resident_set_memory

@williamluke4 I am sorry to hear you are having troubles as reported, can we extract this particular issue into a new issue. Ideally with exact steps how to reproduce. Thanks!

Hi @bpasero, Thanks for your reply.
I do not feel that it would require a separate issue as it seems that having the ability to set the maximum number of open files would mitigate the issue.
If you don't feel that would be the case then I would be happy to create another issue.

Hi everyone, I want this toooooo! Always set it to 3 tabs maximum from other IDE. I'm switching from PHPStorm to VSCode just because my PS license going to expire (LOL) & VSCode is great

All we need is the ability for an extension to close arbitrary tabs. Even just the ability to close the oldest (most un-recently used) tab would probably be good enough.

How have we been asking for this since 2016 and it still hasn't happened? This is a really important feature for a lot of people.

please

I would also like this feature. How many people need to request this feature before it becomes a priority?

+1 for this feature. Really usefull

+1

I've searched multiple times for a way to do this - my workflow in Atom, and Sublime before that, was to have a shortcut to close old tabs so only the N newest tabs remain (but no automatically closing tabs).

+1

+1

I pushed a first version of this with the following new settings (off by default):

  • workbench.editor.limit.enabled [default: false]: Controls if the number of opened editors should be limited or not. When enabled, less recently used editors that are not dirty will close to make space for newly opening editors.
  • workbench.editor.limit.value: [default: 10]: Controls the maximum number of opened editors. Use the workbench.editor.limit.perEditorGroup setting to control this limit per editor group or across all groups.
  • workbench.editor.limit.perEditorGroup [default: false]: Controls if the limit of maximum opened editors should apply per editor group or across all editor groups.

Peek 2019-12-19 13-06

The way it works currently is that dirty editors will never be closed but they do count into the maximum number of editors. So if you have 10 editors dirty opened and open the 11th, this editor will get replaced with other editors opening until one of the other 10 editors are saved.

Happy for feedback when this is available generally in our insiders build (https://code.visualstudio.com/insiders/).

I am closing this issue and suggest to report bugs or additional feature requests as separate issues. Our repository will open again for business later today and the change will be released in insiders for people to try out later today as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisdias picture chrisdias  ·  3Comments

trstringer picture trstringer  ·  3Comments

curtw picture curtw  ·  3Comments

villiv picture villiv  ·  3Comments

philipgiuliani picture philipgiuliani  ·  3Comments