有没有办法在Sublime Text 2中更改行结束样式?

时间:2014-03-17 13:05:34

标签: sublimetext2 linestyle

是否有此设置?

Sublime Text使用行尾样式自动填充大括号(花括号)。工作中的公约是使用行首(或Allman)风格。这是可配置的吗?

1 个答案:

答案 0 :(得分:0)

也许不是实现这一目标的最佳方式,因为这不是项目或语言特定的,是编辑~/Library/Application Support/Sublime Text 2/Packages/User/Default (OSX).sublime-keymap(或适合您的操作系统的文件)并添加:

{ "keys": ["{"], "command": "insert_snippet", "args": {"contents": "\n{\n\t$0\n}"}, "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 }
  ]
}

当按下 {时,这将导致以下行为,当前一个字符为)

enter image description here enter image description here