VSCode:打开不在新选项卡中的文件,重用当前选项卡 [英] VSCode: Open files NOT in a new tab, reuse current tab

查看:53
本文介绍了VSCode:打开不在新选项卡中的文件,重用当前选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信预览功能没有涵盖这一点.我只想通过快速打开(或任何方式?)打开一个文件进行编辑并替换活动选项卡的内容,关闭打开的文件并将其替换为新的.

I believe that this is not covered by the Preview feature. I simply want to open a file for editing via Quick Open (or any way?) and replace the contents of the active tab, closing the open file and replacing it with the new one.

这种行为是我编辑方式的核心.目前,我总是打开我不想要的新标签.这是 Code 和我 15 年来使用 Vim 的方式之间唯一的障碍.我想这是可以编写脚本的,但希望避免走这条路.请告诉我我遗漏了什么.

This behavior is central to the way I edit. Currently, I'm always opening new tabs that I don't want. It's the only barrier left between Code and the way I've used Vim for 15 years. I imagine that this is scriptable, but would like to avoid going down that road. Please tell me I'm missing something.

推荐答案

(1) 极端方法:在您的设置中搜索这些:

(1) The drastic approach: search for these in your settings:

工作台>编辑器限制:启用启用此

工作台>编辑器限制:值设置为1

太严重了,因为它会限制您只能使用 1 编辑器选项卡,这可能不是您想要的,但它当然会重用活动的(也是唯一的选项卡).

Drastic, because it will limit you to only 1 editor tab, probably not what you want but it does reuse the active (and only tab) of course.

(2) 宏观方法:

使用像 multi-command 这样的宏扩展将其放入你的 settings.json

Using a macro extension like multi-command put this into your settings.json

"multiCommand.commands": [

  {
    "command": "multiCommand.openFileInActiveEditor",
    "sequence": [
      "workbench.action.closeActiveEditor",
      "workbench.action.acceptSelectedQuickOpenItem",
      "workbench.action.closeQuickOpen"   // if you want to close the quickopen panel immediately
    ]
  }
]

在 keybindings.json 中:

and in keybindings.json:

{
  "key": "alt+0",  // whatever you want
  "command": "extension.multiCommand.execute",
  "args": { "command": "multiCommand.openFileInActiveEditor" },
  "when": "inFilesPicker && inQuickOpen"
},

您似乎无法从 quickOpen 面板覆盖通常的 right 键绑定,因此我将其设置为 alt+right,但您可以选择你想要的任何东西.

It appears that you cannot override the usual right keybinding from the quickOpen panel so I set it to alt+right instead but you can pick whatever you want.

这篇关于VSCode:打开不在新选项卡中的文件,重用当前选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆