very interesting thread -- inspired me to try making some changes to the 
JavaScript grammar.

Learning about ctrl-command-T and them command-4 to find out what snippet is 
run was interesting.

I'd like to have similar indentation behavior when entering return in a pair of 
square braces in JavaScript. I found a solution (listed below) -- but then 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.

Using comand-ctrl-T and then command-4 and entering return when my cursor was 
after an opening curly brace produced empty results.

How do I find the code that produces the indentation after entering return when 
my cursor is after an opening curly brace produced empty results.

--- more details ---

When I am editing in JavaScript and have a document that contains content like 
this""

  "destinations": [
    {
      "type": "timeSeries",
      "componentIds": [
        "angle-graph"
      ],
      "properties": [
        "currentAngle"
      ]
    },
    {
      "type": "timeSeries",
      "componentIds": [
        "last-run-table"
      ],
      "properties": [
        "rodLength",
        "ballMass",
        "startingAngle",
        "period"
      ]
    }
  ]

If I put my cursor here (just after "{" char) and press return

  "destinations": [
    {

I get a return and approriate indentation:

  "destinations": [
    {
      <=cursor-is-here

I often also find myself wanted to add another item to the array of items and 
would like to have a similar indentation rule applied when entering return at 
the end of this line:

  "destinations": [


I started with something simpler -- enable an indentation to appear when 
entering return with the cursor in the middle of two square brackets.

So this:
[]

Changes to this after entering return
[
  <=cursor-is-here
]

By adding this to the JavaScript Language Grammers:

                {       comment = 'Allows the special return snippet to fire.';
                        match = '(\[)(\])';
                        captures = {
                                1 = { name = 
'punctuation.section.array.begin.js'; };
                                2 = { name = 
'punctuation.section.array.end.js'; };
                        };
                },


So I tried to use the same technique to find out what textmate was doing when 
my cursor is at the beginning of a curly brace and I get an indentation when 
entering return -- when the opening brace is followed by more content before 
the ending brace.

Using comand-ctrl-T and then command-4 and entering return produced empty 
results.

_______________________________________________
textmate-dev mailing list
textmate-dev@lists.macromates.com
http://lists.macromates.com/listinfo/textmate-dev

Reply via email to