Tidy Tabs, but for VSCode? - visual-studio-code

I really miss the "tidy tabs" extension that automatically closes tabs older than a certain age in Visual Studio. Is there any extension for VSCode with similar functionality?

As of version 1.42, we can now set a maximum number of tabs to leave open in each window, which effectively replicates tidy tabs.
Limit 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.

There is zentabs (inspired by zentabs for Sublime Text). It works but with some caveats:
It only closes an old tab when a new one is opened, so it won't help to clean up an existing tab-heavy session, but it should help to prevent it from growing any larger.
Due to VSCode extension limitations, it will briefly switch to any tab it decides to close. You may see this as a temporary flicker when you open a new tab.
As a result, it will sometimes bump the old closed window up to the top of the most-recently-used list on Cmd-P / Ctrl-P, which can be unintuitive.
It also asks you to disable the preview feature (opening unpinned tabs when stepping through searches). That is a shame because that VSCode feature let us do a lot of searching without cluttering our tabs too much.
Under some circumstances (when using search?) I end up with more tabs open that my prescribed limit.
If a file is unsaved when its tab is closed, VSCode will show a popup asking if you want to save the file.

Related

Is it possible the prevent VS-Code from closing a file?

For context; I have a markdown file named tasks.md as a pinned tab in which I keep my todo-list. I'm accustomed to hitting Ctrl + w to close all unused files, but it also closes this pinned tab.
Is it possible to designate a file as "impossible" to close without changing a vscode setting?
Sept. 2020, with VSCode 1.50, the PR 106385 will fix that issue.
Addresses a couple of pain points with pinned tabs:
Pinned tabs: add a setting to show more context #98161
Support pinned tabs when tabs are disabled #100211
Prevent closing the pinned tab when using Ctrl + W #100738
Regarding the context, this comment from Benjamin Pasero (who is part of the development team for VSCode) adds:
After a bit more thought I decided to make normal the default option for the pinnedTabSizing option because it makes sense to have the default be the normal choice and I feel that forcing a pinned tabs to shrink maybe unexpected for users that see this for the first time.
Setting it to compact or shrink should be an explicit choice by the user and is then a lot more understandable.
With VSCode 1.51 (Oct. 2020):
More prominent pinned tabs
Pinned tabs will now always show their pin icon, even while inactive, to make it easier to identify them.
If an editor is both pinned and contains unsaved changes, the icon reflects both states.
Without changing settings: Keyboard Binding Logic File > Preferences > Keyboard Shortcuts it's not possible currently. Upvote this Prevent closing the pinned tab when using Ctrl + W feature request in the VS Code Issue tracker. It'll get to VS Code Dev's backlog if it gets more than 20 upvotes in 60 days (August 21, 2020).

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.
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:
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.
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.
You can get additional info here.

VSCode: How to turn off auto select in File Explorer when changing window tabs?

In VSCode, if I have an editor window tab open and I click anywhere in that editor window, the selected file in the File Explorer changes to the file being edited. I would like to prevent that behavior. This is possible in Visual Studio, but I can't seem to find a similar setting in the preferences file of VSCode.
Can anyone provide some suggestions?
This has been added, see https://github.com/Microsoft/vscode/issues/14745.
Configuration is "explorer.autoReveal": false
You can't, at least not today. The only thing you can do, is keeping the scroll position when switching tabs. See this answer for the setting: VSCode prevent file Explorer from jumping
And here is the feature request on Github: https://github.com/Microsoft/vscode/issues/14745
(Feel free to add a "Thumbs Up" via Github Reaction at the top so the request gets more attention in the future, this increases the chances that it gets implemented sooner)

Can Eclipse hold multiple different 'Compare' windows at the same time?

Like in the topic - is there any default way or any plugin that lets you have multiple 'Compare' windows open and active at the same time? I find it very frustrating that while doing changes to few files at the same time, I can't have active 'Compare' window for each of them, to see my changes/original code.
I would use Window -> New Window, rerun Team -> Show History and then compare another file.
A compare window in Eclipse is placed inside a normal editor tab.
You can have several editor tabs, including compare windows, visible at the same time. To do this just drag the editor tab (the one on the top with the editor name) to somewhere inside the editor area. The editor area will get split in two, each one displaying one editor.
This works with more than two editors also.
If you find that you need more space for the compare windows because other views take up much space you can maximize the editor area by pressing Ctrl+M while the editor area has focus.
Example:
Go to preferences -> team -> General Team Preferences. For me, the "Reuse open compare editors when opening comparisons" was already checked by default. I unchecked that and now I can have multiple file comparison windows open! (I'm using Eclipse Oxygen.3a -- 4.7.3a)

Eclipse auto close unused tabs

I have this habit of looking into other source codes from different projects for a reference. However, this leads to cumulative issue of forgetting to close the tab. I may have around 100 source tabs opened up (which is related to current and unrelated projects).
Is there a preference or plugin to auto close unused tabs after certain idle period? Like say after 10 minutes of inactivity.
The issue I face is when I'm in a hurry the tabs pile up and consume lots of memory, and not to mention if you have opened up Chrome for reading documentation and StackOverflow digging. Finally slows down my system due to swap usage.
[ Update ]
Found some interesting tips from this link
So how to quickly close unnecessary tabs in Eclipse?
Closing tabs one by one by clicking on the tab with a wheel/MMB. It’s faster than clicking LMB on a small cross icon, because it’s enough to click anywhere on a surface of a tab. I do it when there is few tabs to close (like one or two) and tabs that I want to closearen’t hidden.
Closing current tab using Ctrl+W keystroke. I do when tab to be closed happens to be an active tab. And when I just visited some class to check something and I won’t need to revisit it anymore soon.
Using Ctrl+Shift+W keystroke to close all tabs. I do it when I’m starting completely new tasks or at the moment I’m too lazy for 4 or 5. :-) .
Right-clicking on the tab that should stay open and selecting “Close all others” option. It’s handy in cases where only one editor is significant and others are a result of code exploration.
This is my favourite one: Using ctrl+shift+e keystroke to display “Open editors” dialog, selecting editors that should stay open (with ctrl pressed), “invert selection”, “close all selected” and finally hitting esc to close the dialog. It may seem complex but trust me it isn’t. It took me only a few attempts to learn how to use this trick effectively. I often do it when I forgot to close tabs for a while and I have a lot of tabs open and what’s worse, some of tabs aren’t visible on tabs bar (arrow icon needs to be clicked to see the hidden tabs).
There is a feature General > Editors > Close editors automatically which closes unused editors automatically.
There is no auto-close feature/plug-in in eclipse. Because user opened all the editors manually and he/she has to close these on their wishes but not automatically.
For your problem I suggest you to use Mylyn plug-in so that you can stick to only those editors(context) you frequent used, hiding all other editors, packages, classes etc.
Also there is an eclipse plug-in for pinning editors refer my answer for the post Eclipse - How to pin editor tabs?