visual-studio-code - 在 VS Code 中一次击键执行多个命令
问题描述
下面是由多个命令组成的操作的一个示例。我想复制一行,复制它,然后,我需要返回上面的行并将其注释掉。目的是达到以下状态。
previousStatement();
// statementToBeMultipliedAndCommentedOut();
statementToBeMultipliedAndCommentedOut();
nextStatement();
今天,我通过这样的快速组合实现了这一目标。
ctrl+ c
ctrl+ v
up
ctrl+ k+ c//注释掉
down
有没有办法让组合在单个键绑定中执行这些击键?
解决方案
你需要一个宏扩展,比如多命令,这样你就可以运行一系列命令。还有其他宏扩展。使用多命令:
在 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"
},
推荐阅读
- php - 如何将 PHP-FPM 与别名目录一起使用
- python - Python过滤字典列表
- reactjs - React js按钮刷新并加载新数据集
- kendo-ui - 剑道网格中的动态加载器?
- javascript - 将结果映射到反转 ReactJS
- lambda - 如何将 lambda 表达式传递给使用反射调用的方法
- c# - 如何使用 NPOI Excel .NET 获取依赖单元格
- git - 如何在经历了多次提交的文件中查看开始和结束之间的更改?
- android - FileOutputStream 上的文件不是文件异常 - 从移动应用程序下载文件 - android
- r - 如何为R中的变量分配颜色?