To customize Sublime Text's behaviour on when to indent newlines, depending on the current line, one can change the whatever.tmPreferences
file appropriately setting the increaseIndentPattern
and decreaseIndentPattern
options, like shown for example in this other answer.
However, I can't seem to work out how to generate the following behaviour: given a line like
[<cursor here>]
with the cursor between the square brakets, pressing enter
I want the following result:
[
<cursor here>
]
This is for example what happens when modifying an xml
file one presses enter between two brackets, like in <sometag><cursor here></sometag>
.
I tried to look into the tmPreferences
files for the xml
but to no avail.
A similar question has been asked here, but the present one is different for several reasons:
- I want this behaviour to be implemented only for specific file extensions, and to be shipped with a package. So I'm also asking where exactly I should put the instructions for this custom keybinding.
- In the linked question the matter is simpler: to just correctly add and indent newlines between some kind of braces. It is not straightforward (to me) how to generalize this behaviour as in the example cited above in which we want a newline between XML-like tags, as in this case we will have to somehow deal with regexes and verify that the left and right patterns match.
How can this behaviour be implemented?