Have a setting for maximum number open files (editors)
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!
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):
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-saveis 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+erecent-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.