Sublime text 3自动匹配降价中的星号和反键

时间:2017-11-27 06:10:11

标签: sublimetext3 markdown

编辑markdown文件时,我想使星号和反引号表现得像圆括号。例如,我做了一个选择,然后按f = open(self.row, 'r') #file open for line in f.xrealines(): if not line.strip() : #check if a line is empty or not continue else: #I want to skip one line and then adjust next line. row = line.strip('Wn').split(".') ,我希望将所选内容括在两个*个字符中。

如何在Sublime Text 3中执行此操作?

1 个答案:

答案 0 :(得分:1)

要使反向标记(`)的行为与其他匹配字符的行为完全相同,即添加结束对,附加选择,在开启反向标记后退出时删除结束对,将其添加到用户的窗格在Sublime中>偏好>键绑定:

{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`$0`"}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true },
        { "key": "preceding_text", "operator": "not_regex_contains", "operand": "[`a-zA-Z0-9_]$", "match_all": true },
        { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double - punctuation.definition.string.end", "match_all": true },
        { "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }
    ]
},
{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`${0:$SELECTION}`"}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "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": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true },
        { "key": "selector", "operator": "not_equal", "operand": "punctuation.definition.string.begin", "match_all": true },
        { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double - punctuation.definition.string.end", "match_all": true },
        { "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }
    ]
},
{ "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "preceding_text", "operator": "regex_contains", "operand": "`$", "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true },
        { "key": "selector", "operator": "not_equal", "operand": "punctuation.definition.string.begin", "match_all": true },
        { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double - punctuation.definition.string.end", "match_all": true },
        { "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }
    ]
}

我从Sublime的默认键绑定中复制了此代码,用于双引号(“),将”\“”替换为“”“。 这些设置只会影响降价。例如,要解决JavaScript文件,您可以将“text.html.markdown”替换为“source.js”。