【发布时间】:2012-12-11 12:10:17
【问题描述】:
Sublime 有这种行为,有时当你必须输入带有大量括号的结构时,这真的很烦人。当您输入( 时,它会添加() 并将光标放在中间,一切都很好,但是如果您输入),它会默默地吞下右括号。
在输入长正则表达式时这真的很烦人,因为括号很快就会变得不平衡,这让我发疯。所以你最终会得到像(([a-z]) 这样的结构。
所以问题是 - 有没有办法禁用它?如果我输入一个右括号,我希望它留下来,而不是被吞掉。
我已经检查过 Sublime 配置,谷歌搜索,但似乎没有人介意这种行为。我用错了吗?
更新
您可能还想查看Sublime: Jump out of matching brackets 快捷方式。
完整版允许您使用() 输入,但如果您输入了任何文本,则不会吞下结束符号:
{ "keys": ["\""], "command": "insert", "args": {"characters": "\""}, "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": "preceding_text", "operator": "regex_contains", "operand": "[^\"]$", "match_all": true }
]
},
{ "keys": [")"], "command": "insert", "args": {"characters": ")"}, "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": "preceding_text", "operator": "regex_contains", "operand": "[^(]$", "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": "preceding_text", "operator": "regex_contains", "operand": "\\($", "match_all": true }
]
},
{ "keys": ["'"], "command": "insert", "args": {"characters": "'"}, "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": "preceding_text", "operator": "regex_contains", "operand": "'$", "match_all": true }
]
},
{ "keys": ["]"],"command": "insert", "args": {"characters": "]"}, "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": "preceding_text", "operator": "regex_contains", "operand": "[$", "match_all": true }
]
},
{ "keys": ["}"], "command": "insert", "args": {"characters": "}"}, "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": "preceding_text", "operator": "regex_contains", "operand": "{$", "match_all": true }
]
}
【问题讨论】:
-
虽然我不熟悉它,但这篇 SO 帖子提供了一些信息。在 BracketHighLighter 插件上,这可能会提供一些缓解:stackoverflow.com/questions/10372004/how-to-change-style-of-matched-brackets-in-sublime-text-2。
-
谢谢,但这是为了突出括号。我试图找到的是当光标位于右括号并且您正在输入时防止括号丢失的方法。
-
解决该问题的另一种方法是暂时关闭括号匹配 - 例如:在使用 RegEx 时。这个答案就是这样做的:superuser.com/questions/392200/…
-
就是这么简单! :O
标签: autocomplete sublimetext2 editing brackets