下面是一个包含多个命令的操作示例。我想复制一行,使其重复,然后,我需要返回上面一行并注释掉。目的是达到以下状态。
previousStatement();
// statementToBeMultipliedAndCommentedOut();
statementToBeMultipliedAndCommentedOut();
nextStatement();
今天,我通过这样的快速组合实现了这一目标。
ctrl + c
ctrl + v
上
ctrl + k + c //注释
下
有没有办法使一个组合在单个键绑定中执行那些击键?
答案 0 :(得分:1)
您需要像multi-command这样的宏扩展名,以便您可以运行一系列命令。还有其他宏扩展。使用多命令:
在settings.json中:
"multiCommand.commands": [
{
"command": "multiCommand.commentDown",
"sequence": [
"editor.action.copyLinesDownAction",
"cursorUp",
"editor.action.addCommentLine",
"cursorDown"
]
}
]
这些命令可以在“键盘快捷键”列表中找到。在SO上搜索“多命令”以查看您可以使用它做的一些事情。 (我没有联系。)
在keybindings.json中选择一个键绑定:
{
"key": "ctrl+shift+/",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.commentDown" },
"when": "editorTextFocus"
},