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

使用Command Variable扩展在VSCode配置文件中扩展变量的可行性咨询

在VSCode的keybindings/tasks/inputs中扩展自定义变量的问题

想确认是否可以借助Command Variable扩展(v1.49.1),在VSCode的keybindings.json、tasks.json的inputs配置中扩展任意VSCode变量。以下是两次失败的尝试:

1. keybindings.json中的配置尝试

尝试通过快捷键触发全局搜索,将filesToInclude指定为当前打开文件,但${command:mypointer}未被扩展为目标路径,所有extension.commandvariable相关变量均未生效:

{
    "key": "ctrl+'",
    "command": "workbench.action.findInFiles",
    "args": {
        "query": "whatever",
        "replace": "",
        "isRegex": true,
        "filesToInclude": "${command:mypointer}",
        "command": {
            "mypointer": {
              "command": "extension.commandvariable.file.filePosix"
            }
        }
    }
}

2. tasks.json中的inputs配置尝试

尝试通过任务调用全局搜索,分别用${input:fname}、${extension.commandvariable.file.filePosix}、${command:extension.commandvariable.file.filePosix}指定当前打开文件作为搜索范围,但均未成功扩展:

"tasks": [     
    {
        "label": "my_task",
        "command": "${input:call_built_in_function}",
        "problemMatcher": []
    }
],
"inputs": [
    {
        "id": "fname",
        "type": "command",
        "command": "extension.commandvariable.file.filePosix"
    },
    {
        "id": "call_built_in_function",
        "type": "command",
        "command": "workbench.action.findInFiles",
        "args": {
            "query": "whatever",
            "replace": "",
            "isRegex": true,
            "filesToInclude": "${input:fname}"
        }
    }
]

执行结果

截图显示搜索范围被解析为字符串${input:fname}而非实际文件路径,搜索结果为空,提示“在1个文件中未找到匹配项”,但实际目标文件中存在对应内容。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 23:30:32