多个“命令"在单个Sublime Text 2用户键盘映射快捷方式中 [英] multiple "commands" in a single Sublime Text 2 user keymap shortcut
问题描述
有没有一种方法可以将多个命令"与一个快捷方式相关联?
Is there a way to have multiple "commands" associated with one shortcut?
我有这两个捷径.第一个快捷方式使左侧的窗口大于右侧的窗口(在2列视图中),第二个快捷方式使焦点位于第一个窗口上.快速编码时,我往往会忘记一个或另一个快捷方式.
I have these two shortcuts. First shortcut makes the window on the left larger than the right one (in a 2 column view) and the next shortcut puts the focus on the first window. I tend to forget one or the other shortcut when coding quickly.
{
"keys": ["super+alt+left"],
"command": "set_layout",
"args":
{
"cols": [0.0, 0.66, 1.0],
"rows": [0.0, 1.0],
"cells": [[0, 0, 1, 1], [1, 0, 2, 1]]
}
},
{ "keys": ["ctrl+alt+left"], "command": "focus_group", "args": { "group": 0 } }
这个问题让我听起来很懒,但是我想把它看作是有效的.
This question makes me sound like i'm lazy but i'd like to think of it as being efficient.
有什么建议或建议吗?
推荐答案
安装命令链"插件(在ST2和ST3中均可用):
https://github.com/jisaacks/ChainOfCommand
https://packagecontrol.io/packages/Chain%20of%20Command
Install the "Chain of Command" plugin (works in both ST2 and ST3):
https://github.com/jisaacks/ChainOfCommand
https://packagecontrol.io/packages/Chain%20of%20Command
然后,您将可以执行以下操作:
Then you'll be able to do stuff like:
{ "keys": ["ctrl+d"],
"context": [
{ "key": "panel_visible", "operator": "equal", "operand": true }
],
"command": "chain",
"args": {
"commands": [
["hide_panel", {"cancel": true}],
["find_under_expand"],
]
},
},
它重新定义了Ctrl + D,以便在查找"面板打开时将其关闭,然后执行其常规操作(快速添加下一个").
which redefines Ctrl+D so that it'll close the Find panel if it's open, then perform its normal action (Quick Add Next).
您可以执行任意数量的子命令.每个都是一个数组,其中包含命令名称(例如"hide_panel"
)和可选的参数(例如{"cancel": true}
).
You can do any number of subcommands. Each is an array with the command name (e.g. "hide_panel"
) followed optionally by the arguments (e.g. {"cancel": true}
).
这篇关于多个“命令"在单个Sublime Text 2用户键盘映射快捷方式中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!