我已经从 Netbeans 转向 Sublime Text,这只是让您远离梦想设置的其中一件小事。
如果你在大括号中间按回车键,它会这样做:
$var = {
| <-- cursor
}
但是当你在圆括号或方括号中这样做时,它会这样做:
$var = (
|)
和
$var = [
|]
我在设置花括号的键绑定(bind)中找不到。知道我怎样才能让这两个像花括号一样工作吗?提前致谢。
最佳答案
不确定您使用的是什么系统,但可以在 OSX 键映射文件的第 418 行找到此键绑定(bind)。
{ "keys": ["enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line in Braces.sublime-macro"}, "context":
[
{ "key": "setting.auto_indent", "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 }
]
}
当您按下 enter
时,它会运行宏文件 res://Packages/Default/Add Line in Braces.sublime-macro
。 preceding_text
和 following_text
是定义命令何时运行的正则表达式。
默认情况下,它被设置为仅在光标前面有花括号,后面有花括号时运行。您可以更新正则表达式以包含圆括号和方括号,它也会在光标位于它们之间时运行。
关于sublimetext - 在括号中间按 Enter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29119887/