You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSCode树视图中设置固定图标而非仅Hover显示的方法

让VSCode树视图内联图标固定显示的解决方案

要让树视图中的内联图标无条件显示(而非仅鼠标悬停时显示),只需修改package.json中menus配置里的group字段:

修改步骤

  • 针对view/item/context下的内联命令,将group: "inline"修改为group: "inline@0"(或其他数字权重,数字越小显示优先级越高)
  • 确保when条件覆盖你需要显示图标的所有场景

修改后的完整配置示例

"commands": [
    {
        "command": "fileExplorer.refreshFile",
        "title": "Refresh",
        "icon": {
            "light": "resources/refresh-flat.png",
            "dark": "resources/refresh-flat.png"
        }
    },
    {
        "command": "fileExplorer.refreshRoot",
        "title": "Refresh",
        "icon": {
            "light": "resources/refresh-flat.png",
            "dark": "resources/refresh-flat.png"
        }
    },
    {
        "command": "fileExplorer.openFolder",
        "title": "View in Explorer",
        "icon": {
            "light": "resources/folder-open.png",
            "dark": "resources/folder-open.png"
        }
    },
    {
        "command": "fileExplorer.openFile",
        "title": "Open File"
    }
],
"menus": {
    "view/title": [
        {
            "command": "fileExplorer.refreshRoot",
            "when": "view == fileExplorer",
            "group": "navigation"
        }
    ],
    "view/item/context": [
        {
            "command": "fileExplorer.refreshFile",
            "when": "view == fileExplorer",
            "group": "inline@0"
        },
        {
            "command": "fileExplorer.openFolder",
            "when": "view == fileExplorer",
            "group": "inline@1"
        }
    ]
}

原理说明

VSCode默认的inline组会将内联操作设置为仅鼠标悬停时显示,通过给group添加@数字的权重后缀,会强制让图标始终显示在树项旁。权重值越小,图标显示的位置越靠前。

内容的提问来源于stack exchange,提问作者qg_java_17137

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 02:05:14