是否可以在vs codium中的键界中使用输入变量?

发布于 2025-01-26 22:12:07 字数 1549 浏览 3 评论 0原文

在Visual Studio Codium中,我想定义具有可变参数的命令。

我希望IDE打开特定文件,该文件写在另一个文件中。假设我有以下项目结构:

/home/user/myproject/
/home/user/myproject/dir1/
/home/user/myproject/dir1/problem1.py
/home/user/myproject/dir1/problem2.py
/home/user/myproject/dir2/problem1.py
...
/home/user/myproject/pointer.txt

pointer.txt包含我要处理的文件的路径。例如,它包含: dir1/Quards1

我已经阅读了文档在这里。现在,我创建了以下构造:

keybindings.json

    {
        "key": "numpad3",
        "command": "htmlRelatedLinks.openFile",
        "args": {
            "file": "${workspaceFolder}/${input:mycatinput}.py",
            "method": "vscode.open",
            "viewColumn": 2,
        }
    },

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "mycat",
            "type": "shell",
            "command": "cat /home/user/myproject/pointer.txt"
        },
    ],
    "inputs": [
        {
          "id": "mycatinput",
          "type": "command",
          "command": "workbench.action.tasks.runTask",
          "args": "mycat"
        }
    ]
}

但是,当我按NumPad3时,我会收到带有文本的错误通知:无法打开'' $ {输入:mycatinput} .py':找不到文件。

我缺少某些东西吗?如何在keybindings.json命令中指定一个变量,该变量本身是另一个命令(shell命令,而不是vscode命令)的结果。

In Visual Studio Codium I want to define a command that has a variable parameter.

I want the IDE to open specific file, which name is written in another file. Assume I have the following project structure:

/home/user/myproject/
/home/user/myproject/dir1/
/home/user/myproject/dir1/problem1.py
/home/user/myproject/dir1/problem2.py
/home/user/myproject/dir2/problem1.py
...
/home/user/myproject/pointer.txt

The pointer.txt contains path to the file I want to work on. For example, it contains:
dir1/problem1.

I have read the documentation here. Now I created the following construction:

keybindings.json:

    {
        "key": "numpad3",
        "command": "htmlRelatedLinks.openFile",
        "args": {
            "file": "${workspaceFolder}/${input:mycatinput}.py",
            "method": "vscode.open",
            "viewColumn": 2,
        }
    },

tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "mycat",
            "type": "shell",
            "command": "cat /home/user/myproject/pointer.txt"
        },
    ],
    "inputs": [
        {
          "id": "mycatinput",
          "type": "command",
          "command": "workbench.action.tasks.runTask",
          "args": "mycat"
        }
    ]
}

But when I press numpad3, I get an error notification with text: Unable to open '${input:mycatinput}.py': File not found.

Am I missing something? How do I specify a variable in keybindings.json command, which itself is a result of another command (a shell command, not a vscode command).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文