是否有可能阻止 VS-Code 关闭文件?

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

为了上下文;我有一个名为 tasks.md 的降价文件作为固定选项卡,我在其中保存了我的待办事项列表。我习惯于点击 Ctrl + w 来关闭所有未使用的文件,但它也会关闭这个固定的标签。

是否可以在不更改 vscode 设置的情况下将文件指定为“无法”关闭?

不更改设置:键盘绑定逻辑File > Preferences > Keyboard Shortcuts目前无法实现。点赞此 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(2020 年 8 月 21 日)。

九月2020 年,VSCode 1.50,PR 106385 将解决该问题。

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

关于上下文,this comment from Benjamin Pasero(VSCode 开发团队的成员)补充说:

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.


VSCode1.51(2020 年 10 月):

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.