让我们说,作为一个例子,我想扩展箭头键的功能。当我按住ctrl + z和箭头键时,它会执行重做,撤消,软重做或软撤消,具体取决于我按下的箭头的方向。我做了这个原型并且感觉非常直观(好吧,公平地说,我实际上使用的是vim风格的hjkl导航而不是箭头键,但这是暂时的):
[
{ "keys": ["ctrl+z+left"], "command": "undo"},
{ "keys": ["ctrl+z+right"], "command": "redo"}
]
当我尝试按ctrl + left / right而没有z时出现问题。我希望这可以将光标向左或向右移动一个单词,而是执行我刚刚绑定的撤消/重做。
现在,我完全知道我可以这样做:
[
{ "keys": ["ctrl+z","ctrl+left"], "command": "undo"},
{ "keys": ["ctrl+z","ctrl+right"], "command": "redo"}
]
但它感觉不一样。
如何在不修改ctrl + left / right的行为的情况下绑定ctrl + z + left / right?
答案 0 :(得分:0)
我遇到的解决方案是创建自己的插件。该插件跟踪以前的键命令,并根据其值重定向到其他命令。它在包管理器上可用作" ContextualMove"
这是最简单形式的插件:
{ "keys": ["ctrl+u"], "command": "contextual_move", "args": {"context": "history"} },
{ "keys": ["ctrl+space"], "command": "contextual_move", "args": {"context": "words"} },
{ "keys": ["ctrl+enter"], "command": "contextual_move", "args": {"context": "lines"} },
{ "keys": ["ctrl+tab"], "command": "contextual_move", "args": {"context": "tabs"} },
{ "keys": ["ctrl+f"], "command": "contextual_move", "args": {"context": "find"} },
{ "keys": ["ctrl+i"], "command": "contextual_move", "args": {"direction": "up"} },
{ "keys": ["ctrl+k"], "command": "contextual_move", "args": {"direction": "down"} },
{ "keys": ["ctrl+j"], "command": "contextual_move", "args": {"direction": "left"} },
{ "keys": ["ctrl+l"], "command": "contextual_move", "args": {"direction": "right"} },
{ "keys": ["ctrl+shift+i"], "command": "contextual_move", "args": {"direction": "up", "extend": true} },
{ "keys": ["ctrl+shift+k"], "command": "contextual_move", "args": {"direction": "down", "extend": true} },
{ "keys": ["ctrl+shift+j"], "command": "contextual_move", "args": {"direction": "left", "extend": true} },
{ "keys": ["ctrl+shift+l"], "command": "contextual_move", "args": {"direction": "right", "extend": true} },
以下是我对键绑定所做的编辑:
list.Add(Convert.ToInt32(Console.ReadLine()));