【问题标题】:Showing path in file-tabs in Visual Studio Code在 Visual Studio Code 的文件选项卡中显示路径
【发布时间】:2017-01-28 14:37:24
【问题描述】:

我的项目中有一个基于组件的文件夹结构。它是一堆组件文件夹,每个文件夹都有一个 index.js 文件。

是否可以让 Visual Studio Code 在文件选项卡中显示父文件夹名称?还是我只能看到一堆标签,它们都显示 index.js 而没有其他内容?

【问题讨论】:

  • 此设置将在标题栏中显示完整路径(虽然不是选项卡):“window.title”: “${activeEditorLong}${separator}${rootName}”
  • ${activeEditorMedium}${separator}${rootName} 在 imo 上工作得更好,我没有理由看到文件的整个路径而不是来自 src 根目录的路径

标签: visual-studio-code


【解决方案1】:

您可以将 Visual Studio Code 配置为始终在选项卡中显示父文件夹名称!在您的用户设置中,只需添加这一行:"workbench.editor.labelFormat": "short"(其他值为“long”、“medium”或“default”)

结果:init/views.jsinit/routes.jsplugins/modal.js 文件将显示为:


另一个选项是用户设置"breadcrumbs.enabled": true,它将为您提供一整行显示完整文件路径的面包屑:


PS:要打开用户设置,请使用文件菜单 → 首选项设置用户设置。要查看 JSON 格式的设置,只需单击右上角的 {} 图标。

【讨论】:

    【解决方案2】:

    进入主菜单文件首选项设置。并搜索 (Cmd + F 在 Mac 上;Ctrl + F 在 Windows 和 Linux 上) workbench标签格式

    选择 选项。

    【讨论】:

    • 搜索结果中有两个"Label Format""Workbench ► Editor: Label Format""Workbench ► Editor ► 无标题:标签格式”
    • 适用于版本 1.45 (2020-04)。
    • 第二个有不同的选项,"Content""Name"
    • 也许使用会导致单次命中的搜索词(目前有10次命中)?
    • 用引号括起来将点击次数从 34 减少到 7(版本 1.45.1,2020-05-14):"workbench label format"
    【解决方案3】:

    Visual Studio Code 现在已改进其选项卡 UI 以解决此问题。

    当您打开多个具有相同文件名的选项卡时,Visual Studio Code 将自动在每个选项卡中显示父文件夹名称。

    这是一个示例:我打开了 event.js 和两个 index.js 文件。 Visual Studio Code 自动决定显示 index.js 文件的文件夹名称是个好主意 :)

    它几乎解决了我的大部分问题。

    【讨论】:

    • 还有一个设置来控制标签的行为和格式:“workbench.editor.labelFormat”
    【解决方案4】:

    我知道现在回答为时已晚,但如果有人正在寻找 file path 以显示在 title bar 上,您可以按照以下步骤操作:

    1. 打开设置 (command + ,)
    2. 搜索title
    3. 您会看到类似activeEditorShort 的内容,将其替换为activeEditorLong
    4. 保存

    来源https://medium.com/riow/vscode-show-full-path-in-title-bar-b0cb731b330

    【讨论】:

      【解决方案5】:

      您可以安装nice-index 扩展以获得更好的处理索引文件的体验。

      但是,到目前为止,它仅在您打开多个索引文件时才有效。正如其他答案所暗示的,这可以通过将 labelFormat 更改为“short”来解决。

      【讨论】:

        【解决方案6】:

        在 VSCode 1.53 中你可以使用这些设置:

        根据活动编辑器控制窗口标题。根据上下文替换变量:

        ${activeEditorShort}: the file name (e.g. myFile.txt).
        ${activeEditorMedium}: the path of the file relative to the workspace folder (e.g. myFolder/myFileFolder/myFile.txt).
        ${activeEditorLong}: the full path of the file (e.g. /Users/Development/myFolder/myFileFolder/myFile.txt).
        ${activeFolderShort}: the name of the folder the file is contained in (e.g. myFileFolder).
        ${activeFolderMedium}: the path of the folder the file is contained in, relative to the workspace folder (e.g. myFolder/myFileFolder).
        ${activeFolderLong}: the full path of the folder the file is contained in (e.g. /Users/Development/myFolder/myFileFolder).
        ${folderName}: name of the workspace folder the file is contained in (e.g. myFolder).
        ${folderPath}: file path of the workspace folder the file is contained in (e.g. /Users/Development/myFolder).
        ${rootName}: name of the opened workspace or folder (e.g. myFolder or myWorkspace).
        ${rootPath}: file path of the opened workspace or folder (e.g. /Users/Development/myWorkspace).
        ${appName}: e.g. VS Code.
        ${remoteName}: e.g. SSH
        ${dirty}: a dirty indicator if the active editor is dirty.
        ${separator}: a conditional separator (" - ") that only shows when surrounded by variables with values or static text.
        

        【讨论】:

        • 虽然这很有用,但与设置编辑器选项卡标题的问题无关。
        【解决方案7】:

        我创建了一个简单的 Visual Studio Code 插件,它接受正则表达式和颜色列表,并根据它们更改 titleBar/tabColor。它非常适合处理单存储库或具有多个包(如 Lerna 或 React + React Native)的大型项目。

        ColorTabs

        【讨论】:

        • 这与原始问题无关。
        • 好吧,这不是直接的答案,而是很好的补充。我会支持
        猜你喜欢
        • 2015-10-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-01-31
        • 2016-06-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多