Skip autocompleted brackets, commas etc. with tab in sublime-text

前端 未结 2 964
终归单人心
终归单人心 2021-01-14 23:15

In sublime, if you type, alert(\"{ it will autocomplete the closing brackets and quotes to: alert(\"{}\").

In v

相关标签:
2条回答
  • 2021-01-14 23:50

    Edit your .sublime-keymap file and add

    // Skip past round and square autocomplete brackets
        { 
            "keys": ["shift+enter"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
            [
                { "key": "following_text", "operator": "regex_contains", "operand": "^[)\"\\]\\}\\$]", "match_all": true },
                { "key": "auto_complete_visible", "operator": "equal", "operand": false }
            ]   
        },
    

    In this case, shift + enter will function like tab in visual studio.

    The solution is originally not mine - I found it either here or on the ST2 forum.

    0 讨论(0)
  • 2021-01-14 23:51

    Building on @AGS's answer and your comment, there are two possible options. The first (if you're not using OS X) is to just hit End, which will move the cursor to the end of the line (eol).

    The second option is to slightly modify @AGS's keymap to the following:

    { 
        "keys": ["shift+enter"], "command": "move_to", "args": {"to": "eol", "extend": false}, "context":
        [
            { "key": "following_text", "operator": "regex_contains", "operand": "^[)\"\\]\\}\\$]", "match_all": true },
            { "key": "auto_complete_visible", "operator": "equal", "operand": false }
        ]   
    }
    

    The binds the eol functionality to ShiftEnter, and includes the regex support, which can be removed if you want.

    I hope this helps!

    0 讨论(0)
提交回复
热议问题