【问题标题】:Keybind setting to skip past auto-pair end characters in Sublime Text 2在 Sublime Text 2 中跳过自动配对结束字符的键绑定设置
【发布时间】:2013-05-24 17:25:33
【问题描述】:

我希望能够让光标移过自动配对结束字符,以便我可以继续输入我的代码。

我是 Sublime Text 的菜鸟。我在这里查看 SO,发现 this post 使用这种类型的代码(sn-p):

//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":[

       ]
    }

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

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

【问题讨论】:

    标签: sublimetext2 key-bindings settings


    【解决方案1】:

    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 上阅读有关键绑定和上下文的更多信息。

    【讨论】:

    • 量角器忍者,谢谢!我不知道为什么“@”符号前缀在我尝试使用它来回复帖子时不起作用我总是必须对用户名进行硬编码。
    • @Chris22 很高兴听到!当user 恰好是您评论的任何内容的作者时,堆栈溢出会删除@user 标记。很多人不喜欢这个——阅读this meta question了解更多详情。
    猜你喜欢
    • 1970-01-01
    • 2015-09-19
    • 2013-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-16
    • 1970-01-01
    相关资源
    最近更新 更多