2

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)
Fellow Stranger
  • 32,129
  • 35
  • 168
  • 232

1 Answers1

7

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 }
    ]
}
skuroda
  • 19,514
  • 4
  • 50
  • 34
  • My god, thank you so much! I had found a temporary solution where I after hitting ENTER did CMD + SHIFT + ENTER ("Insert line before"), but your solution is PERFECTION. PS. Please remove the trailing comma though. Not possible for me to make an edit with less than 6 characters. – Fellow Stranger Apr 02 '13 at 10:40
  • Done. Sorry about that. ST3 handles the commas better than ST2 :) – skuroda Apr 02 '13 at 23:57