Alb*_*ing 6 auto-close sublimetext2
我正在尝试自动关闭*Markdown文件中的星号()字符。
我一直在浏览所有语言设置文件,但没有发现任何可作为示例的内容。我也尝试编写一个代码段,但发现它效率低下(它不会围绕选择内容)。
我四处搜索,发现BracketHighlighter(声称允许自定义自动关闭配对),但是没有运气(通过Package Control安装,也重新启动了)。
关于应该从哪里开始或做错了什么的任何想法?
解决方案(感谢@skuroda)
skuroda的答案会很好-但是,我做了一些调整,我想补充一下他们的答案:
{ "keys": ["*"], "command": "insert_snippet", "args": {"contents": "$0**"}, "context":
[
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\*\\*", "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }
]
}
Run Code Online (Sandbox Code Playgroud)
**如果在前面的两个星号旁边按了星号键,则这将添加两个(例如,**|然后***|变为光标**|**所在的位置|。这对加粗文本很有帮助)。
您可能需要对上下文进行一些调整,但这应该是一个开始。这是基于内置括号的自动配对键绑定。
{ "keys": ["*"], "command": "insert_snippet", "args": {"contents": "*$0*"}, "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": "*${0:$SELECTION}*"}, "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 }
]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1790 次 |
| 最近记录: |