sublimetext - 在括号中间按 Enter

标签 sublimetext sublimetext3

我已经从 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-macropreceding_textfollowing_text 是定义命令何时运行的正则表达式。

默认情况下,它被设置为仅在光标前面有花括号,后面有花括号时运行。您可以更新正则表达式以包含圆括号和方括号,它也会在光标位于它们之间时运行。

关于sublimetext - 在括号中间按 Enter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29119887/

相关文章:

sublimetext3 - Sublime text Split View,顶部 2 列,底部 1 列

python - 这可能吗 > Sublime3 + python linter + virtualenv?

python - 如何突出显示对对象方法和用户创建的函数的调用? (崇高文本, python )

sublimetext3 - 崇高的片段不起作用

visual-studio-code - 如何在多行编辑的末尾添加不同的数字?

c++ - 使用 Sublime Text 3 在 Powershell 中构建 C++ 而不是 CMD

replace - 崇高文本 : interactive confirm for replace?

sublimetext - Sublime Text 正则表达式查找包含 dump 且不以//开头的所有行

sublimetext - 我可以将制表符设置为ruby中的2个空格和javascript中带有 Sublime Text 的4个空格

sublimetext - Sublime Text 3 如何更改文件侧边栏的字体大小?