V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
jakezhu
V2EX  ›  问与答

如何设置 Sublime Text 2 选中代码后键入 markdown 的```自动括起代码,而不是替换

  •  
  •   jakezhu · Mar 15, 2017 · 1265 views
    This topic created in 3330 days ago, the information mentioned may be changed or developed.
    像双引号,括号,大括号之类的字符,比如选中
    v2ex ,键入双引号,变为
    "v2ex"

    那么如何设置选中 v2ex ,键入```之后,变为
    ```
    v2ex
    ```
    Supplement 1  ·  Mar 15, 2017

    已解决。 打开Preferences -> Key Bindings - User,加入

    [
    { "keys": ["`"], "command": "insert_snippet", "args": {"contents": "```\n$0\n```"}, "context":
        [
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|;|\\}|$)", "match_all": true },
            { "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }
    
        ]
    },
    { "keys": ["`"], "command": "insert_snippet", "args": {"contents": "```\n${0:$SELECTION}\n```"}, "context":
        [
            { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true },
            { "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }
        ]
    },
    { "keys": ["`"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
        [
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^\\```", "match_all": true },
            { "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }
        ]
    }
    ]
    
    

    当选中v2ex时,键入`,将变为:

    ```
    v2ex
    ```

    参考http://stackoverflow.com/questions/16025592/custom-bracket-auto-closing-in-sublime-text

    1 replies    2017-03-15 10:50:30 +08:00
    EchoNode
        1
    EchoNode  
       Mar 15, 2017   ❤️ 1
    markdownediting
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1783 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 16:25 · PVG 00:25 · LAX 09:25 · JFK 12:25
    ♥ Do have faith in what you're doing.