In light of this answer https://stackoverflow.com/a/72150541/4335781
with the extension Command Variable
is it possible to get any vscode variable to be expanded in the keybindings.json or in tasks.json/inputs?
using v1.49.1 of Command Variable extension
for example:
{
"key": "ctrl+'",
"command": "workbench.action.findInFiles",
"args": {
"query": "whatever",
"replace": "",
"isRegex": true
"filesToInclude": "${command:mypointer}",
"command": {
"mypointer": {
"command": "extension.commandvariable.file.filePosix"
}
}
}
},
the "${command:mypointer}"
is not expanded to the currently open file none of extension.commandvariable
are expanded in the keybinding.json
I tried also to create a task and get the built in command in inputs
using the same extension.
for example:
"tasks": [
{
"label": "my_task",
"command": "${input:call_built_in_function}",
"problemMatcher": []
}
],
"inputs": [
{
"id": "fname",
"type": "command",
"command": "extension.commandvariable.file.filePosix"
}
,
{
// using inputs, I can pass the arguments of the build in command
"id": "call_built_in_function",
"type": "command",
"command": "workbench.action.findInFiles",
"args": {
"query": "whatever",
"replace": "",
"isRegex": true,
"filesToInclude": "${input:fname}",
// I expected here that the opended editor file name will be used
// However it is not expanded.
//"filesToInclude": "${extension.commandvariable.file.filePosix}",
// this one also does not work
// "filesToInclude":"${command:extension.commandvariable.file.filePosix}"
// does not work neither
}
},
]
attached photo shows the output of using either the keymap shortcut or running the task