[txmt-dev] Re: Working with indentation rules
Allan Odgaard
mailinglist at textmate.org
Fri Sep 20 10:00:43 UTC 2013
On 19 Sep 2013, at 0:06, Stephen Bannasch wrote:
> […] I wanted a similar indentation behavior when pressing return
> after an open square brace followed by content as I get when I enter
> return after an open curly brace followed by content.
> […] How do I find the code that produces the indentation after
> entering return when my cursor is after an opening curly brace […]
By default, no bundle item is executed when you press return at random
places. How much indent is inserted is estimated via the indent rules,
this is explained here:
http://manual.macromates.com/en/appendix#indentation_rules
So if you want only a change to indent, then it’s the indentation
rules that should be changed.
If however you want more complex behavior, you can overload the key
binding with a snippet or command.
For JavaScript, square brackets are assigned the
“meta.brace.square.js” scope.
If we work with the grammar as-is, then we can make a snippet fire on
return only when a square bracket is to the left of the caret by using a
scope selector of:
(L:meta.brace.square.js)
Here the scope selector targets the “left scope” via the (L:…)
syntax, meaning the scope to the left of the caret. You can view the
scope to the right of the caret by pressing ⌃⇧P (so move it one to
the left to view the left scope).
But if your desire is simply to increase the indent, when pressing
return after ‘[’, then it should be enough to edit the indent
patterns (which already target squigly braces).
More information about the textmate-dev
mailing list