【问题标题】:Can't bind command to Spacebar in Sublime Text无法在 Sublime Text 中将命令绑定到空格键
【发布时间】:2021-08-03 17:11:56
【问题描述】:

我正在使用这两个绑定来自动完成:

{
"keys": ["tab"],
"command": "move",
"args": {"by": "lines", "forward": true},
"context":
    [
        { "key": "auto_complete_visible", "operator": "equal", "operand": true }
    ]
},
{
"keys": ["shift+tab"],
"command": "move",
"args": {"by": "lines", "forward": false},
"context":
    [
        { "key": "auto_complete_visible", "operator": "equal", "operand": true }
    ]
},

我想将"commit_completion" 命令添加到space 键:

"keys": ["space"],
"command": "commit_completion",
"context":
    [
        { "key": "auto_complete_visible", "operator": "equal", "operand": true }
    ]
},

但它没有绑定,当我按下space 时,它充当普通空格(它使空格 xD)。我可以将它绑定到任何其他键,但不能绑定到空格。我错过了什么?

【问题讨论】:

    标签: windows macros sublimetext3


    【解决方案1】:

    没有可以像这样绑定的空格键的键码;如果您想将某些内容绑定到空格,则需要使用文字空格字符:

    {
      "keys": [" "],
      "command": "commit_completion",
      "context": [
        { "key": "auto_complete_visible", "operator": "equal", "operand": true }
      ]
    },
    

    通过使用sublime.log_input(True)打开输入日志然后按下键,这在Sublime控制台中可见;唯一记录的是角色事件,而不是关键事件。

    同样重要的是要注意,除非您使用 context 来限制绑定何时应用,否则您永远不想将任何内容绑定到这样的字符,或者您无法键入该字符。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-23
      • 1970-01-01
      相关资源
      最近更新 更多