Sublime Forum

How to make HTML tags behave same as brackets

#1

Hello, first of all excouse my english please :smile:

Maybe guys you can help me.
I wanted editor to react with html tags same way as he reacts with brackets when i hit enter with cursor in the middle of them.

<div>cursor</div>
  • hit enter * (or shift+enter for example)
<div>
	cursor
</div>

Any hint how I can achive that?

0 Likes

#2

Adding this to your user key bindings should do the trick:

<binding key="enter" command="insertInlineSnippet '\n\t$0\n'">
	<context name="option" value="autoIndent"/>
	<context name="allSelectionsEmpty" value="true"/>
	<context name="allPrecedingCharacter" value="&lt;"/>
	<context name="allFollowingCharacter" value="&gt;"/>
</binding>

The equivalent version for brackets is defined in the default key bindings - this is just a slightly reworked version of that.

0 Likes

#3

Had to change “allPrecedingCharacter” to “>” and “allFollowingCharacter” to "< but now it works I wanted.

Thank you for help.

0 Likes