[TxMt] Re: TM2: strange indenting for C++

Allan Odgaard mailinglist at textmate.org
Wed Jan 25 09:00:23 UTC 2012


On 24/01/2012, at 22.54, Christopher Creutzig wrote:

> […] OTOH, as soon as indextNextLinePattern stops matching, we're back to the
> indenting of the line starting the whole thing. What is the intended
> meaning of indextNextLinePattern – indent relative to this line, or
> relative to whatever we'd otherwise use?

The indentNextLine increase the indent relative to the current indent level.

This is kept in a register which is preserved if next line is also matched by the indentNextLine pattern.

An example where this makes sense would be:

  if(true)
    while(false)
      for(size_t i = 0; i < 10; ++i)
        continue;
  return 0;

I don’t think TextMate 1.x is able to properly indent the above, but 2.0 will, even while you type it.

The downside of the line-based rule system is that breaking one statement across multiple lines is effectively unsupported, since each fragment is matched against the patterns and will thus be wrongly classified. I don’t know how this can be improved (other than do binary parsers for each language, but even that is quite a challenge for languages like C++).



More information about the textmate mailing list