Keybind设置跳过Sublime Text 2中的自动对结束字符

时间:2013-05-24 17:25:34

标签: sublimetext2 key-bindings settings

我希望能够让光标移过autopair结束字符,这样我就可以继续键入我的代码了。

我是Sublime Text的菜鸟。我在SO看了一下,发现this post使用了这种类型的代码(片段):

//Tab skips to end of autopaired characters
{ "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true},

然后我添加到我的Default(Windows)sublime-keymap -- User文件中:

//Tab skips to end of autopaired characters
    { "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true},
      "context":[

       ]
    }

当我按下'tab'键使光标移动到关闭的autopair时,光标移动到制表位(默认添加4个空格),它不会向前移动“就像按箭头键一样。

如何使用Tab键或其他键使光标向前移动?我在这里错过了什么/做错了什么?我不想使用箭头键,因为这样做不是来自主页键的自然按键(特别是取决于用户键盘)。谢谢!

1 个答案:

答案 0 :(得分:2)

question you linked实际上是正确的 - 您刚刚删除了context密钥数组,它有效地告诉Sublime Text您从不希望Tab移动向前移动一个字符。使用提问者的完整密钥绑定:

{ "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
    [ 
        { "key": "selection_empty", "operator": "equal", "operand": true },
        { "key": "preceding_text", "operator": "not_regex_match", "operand": "[[:space:]]*", "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^[\"'\\)\\}\\]\\_]", "match_all": true },
        { "key": "auto_complete_visible", "operator": "equal", "operand": false },
        { "key": "has_next_field", "operator": "equal", "operand": false } 
    ] 
},

您可以在Unofficial Docs Key Bindings page了解有关键绑定和上下文的更多信息。