是否可以在vs codium中的键界中使用输入变量?
在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论