Auto-indent new line when hitting enter to expand one-line tag in HTML

元气小坏坏 提交于 2019-12-30 05:21:07

问题


I would like to have this work flow working with HTML in Sublime Text 2:

  1. Create HTML tag (e.g. ctrl + shift + W)
  2. TAB (putting the cursor in the content area)
  3. ENTER

Resulting with this (the word "HERE" indicates where the cursor should be):

<p>
    HERE
</p>

But instead this is what I get (the word "HERE" still indicating the cursor's position):

<p>
HERE</p>

Which demands you to

  1. ENTER (again)
  2. ARROW-UP + TAB
  3. ARROW-UP + TAB (a second time)

回答1:


Try adding the following in your user key bindings.

{ "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 }
    ]
}


来源:https://stackoverflow.com/questions/15750978/auto-indent-new-line-when-hitting-enter-to-expand-one-line-tag-in-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!