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

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).

Related

Close Vscode Panel on killing the last Terminal

Earlier The Panel of vscode used to close when I killed the terminal. But after I reset my pc and reinstall vscode, this is not happening. I after killing all the terminals I have to click on the "Close Panel" Button to close it.
How can I close the panel automatically on killing the last terminal?
Thanks for help in advance.
So the lower panel (or right/left panel if you moved it) should always automatically close if the terminal-view has had all of its terminals closed.
Now, with the above said, their is one exception, which is a common exception: When you show there panel with a view — i.e. the problems view, output-logger, etc... — with the terminal-view, the behavior of the panel changes. In the context I just described, the panel will not automatically close.
To solve the issue, remove all other views that share the panel with the terminal view. Then you should find that you get the expected behavior.
FYI, this has worked this way for a long time, and a while back (2+ years ago) there was a somewhat supported feature request to make the closing behavior of the panel more configurable — e.g. like adding settings that close the panel when the terminal-view has no terminals open, even if it is in a shared panel — however, I checked all settings & release notes and GitHub before answering this, and it appears that the panel & terminal view, in the context of this question, still behave the way that they always have since the first newer release of the non-beta VS Code.

VSCode: Turn auto scrolling permanently ON

In Visual Studio Code, is there any way to force the auto-scrolling option of the Output panel permanently enabled?
At the moment I have to click on the lock button every time I build my project to disable the scroll lock or better to say enable the auto-scrolling feature and this is so annoying.
I took a look at the settings but couldn't find any relevant parameter there.
Any ideas?
An option to turn off the smart scroll feature was included in one of the recent updates (probably in the March 2020 update, I didn't find it in the changelog), see more: issue #69480
Since then, I've been able to "save" the scroll state, try this:
Go to File > Preferences > Settings (or Ctrl + ,)
In Features > Output, disable Smart Scroll option (or search output.smartScroll.enabled)
Tested with VSCode version 1.45.1 and CodeRunner 0.10.0
Smart scrolling allows you to lock scrolling automatically when you
click in the output view and unlocks when you click in the last line
So clicking on the last line will auto scroll to the last line. I made a habit of doing that. Of course disabling Smart Scrolling is the permanent solution.

Tidy Tabs, but for VSCode?

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.

Is there a vscode settings which specifies which tab to open when closing a tab?

After you've close a tab in vscode, the most recently viewed tab gets focus. I would like to change that behavior to instead focus the tab to the right of the closed tab.
Is there a setting to change this?
This feature was added in release 1.31 in January 2019. From the changelog:
Closing order of editor tabs
A new setting workbench.editor.focusRecentEditorAfterClose allows you to change the order in which editor tabs are closed. By default, tabs will close in most recently used (MRU) order. Changing this setting allows closing tabs from right to left instead.
So adding "workbench.editor.focusRecentEditorAfterClose": false to your settings.json should give you the behaviour you want.

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?