是否有一个键盘快捷命令输入指定的文本到输入框(不是编辑器)在VS Code?



我想写一个键绑定,在VS Code中的非编辑器输入框中键入一些东西,例如搜索视图中的查询编辑器输入框或编辑器查找小部件。

我尝试像这样使用"type"命令:

{
"key": ...,
"command": "type",
"args": { "text": "hello world" }
},

但这并没有达到我的预期。它在搜索视图的查询编辑器输入框中似乎没有任何作用,而在编辑器查找小部件的输入框中,它最终将文本参数输入编辑器本身,所以我假设这个命令只是用于在编辑器中输入。

如何做到这一点?(理想情况下不使用扩展,但使用扩展的答案仍然是可以接受的)或者根本不可能?


我试着谷歌"github vscode issues keyboard shortcut "type" into input box";在搜索结果中也没有看到任何有用的东西。对于搜索"is:q keyboard shortcut [vscode] type input box";在Stack Overflow的搜索栏

我不知道在vscode中是否有任何输入框,您可以打开它,关注它,然后添加文本。您可能必须首先打开它,并为其命令提供参数。所以这些参数对于不同类型的输入框是不同的。

对于查找小部件,您可以使用以下命令:

"command": "editor.actions.findWithArgs",
"args": {
// "findInSelection": true,      // doesn't work
"matchCase": false,              // should be isCaseSensitive
// "matchCaseOverride": 0,       // appears to not be implemented
// "preserveCase": true,        
// "preserveCaseOverride": 0,    // appears to not be implemented
"isRegex": true,
// "regexOverride": 1,           // appears to not be implemented
"searchString": "some queryString",
"replaceString": "a replacement string"
// "wholeWord": true,            // should be matchWholeWord
// "wholeWordOverride": 0        // appears to not be implemented
}
对于跨文件搜索,您可以使用以下参数:
"command": "workbench.action.findInFiles",
"args": {
"query": "(enum|struct|fn|trait|impl(<.*>)?|type) ",
"isRegex": true,
"replace": "$1",
// "triggerSearch": true,          // seems to be the default
"filesToInclude": "src, include",  // no variables in findInFiles
// "preserveCase": true,
// "useExcludeSettingsAndIgnoreFiles": false,
// "isCaseSensitive": true,
// "matchWholeWord": true,
// "filesToExclude": ""
}

您可以在宏扩展或内置runCommands中使用这些命令及其args

相关内容

最新更新