<div>
This line needs to be indented and closing div tag should be in a new line</div>
<div>
This result is what I want
</div>
在Sublime Text 2中,按ctrl + shift + W并按“enter”创建标签后,我希望结果如上所示。我是否必须安装插件或者我错过了什么?
答案 0 :(得分:4)
认为您正在尝试执行与此问题相同的操作 - Auto-indent new line when hitting enter to expand one-line tag in HTML。
以下是我的答案。
尝试在用户密钥绑定中添加以下内容。
{ "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n\t$0\n"}, "context":
[
{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
{ "key": "selector", "operator": "equal", "operand": "meta.scope.between-tag-pair", "match_all": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
]
}
答案 1 :(得分:0)
尝试此键绑定:
{ "keys": ["ctrl+shift+w"], "command": "reindent" , "args": {"single_line": false}}
答案 2 :(得分:0)
如果您安装Tag plugin,我认为这是一个更通用的解决方案。如上所述Dardub on his answer,Tag插件也可以通过package control获得。
如果您选择Tag插件,最简单的使用方法是突出显示要缩进的文本,然后按快捷键 Ctrl + Shift + F < / KBD>
如果您坚持 Enter 工作流程,只需将此行添加到您的密钥绑定中:
{ "keys": ["enter"], "command": "tag_indent_document" }
但要小心,因为取代了 Enter 默认行为。
避免需要文本突出显示的更保守的方法是使用更具体的绑定:
{ "keys": ["super+shift+f"], "command": "tag_indent_document" }
现在缩进所有HTML / XML只需按快捷键 Super + Shift + F 。