[TxMt] Autonumbering in a bundle

Michael Sheets mummer at whitefalls.org
Mon Jun 18 15:11:55 UTC 2007


On Jun 18, 2007, at 6:10 AM, Pieter Baele wrote:

> Right at the moment I've only some syntax highlighting, but I' did  
> like to know how
> I can implement auto-numbering.
> I am only a beginner with these bundles.

What you can do is make a command that uses return as the trigger,  
find the current lines number with the TM_CURRENT_LINE variable and  
then insert a newline and the next number.

Now this doesn't take into account inserting something in the middle  
of some already created lines. For that you'd need a renumber all  
lines command, should be pretty simple to write.

> Each line ends after 80 columns (or characters)
> Is it possible to always(!) wrap after 80 chars?

Automatically wrap no, in the grammar you could mark any content  
after 80 as invalid but that's it. Even that wouldn't take hold for  
items starting before 80 and going after. You can set the wrap column  
at 80 so you have the visual indicator. And you could also have the  
return command automatically make any line that's too long two lines.  
(If you can make it smart enough to know where to split it)

> Another issue: commenting; cobol uses a star in column 7 to show a
> line is comment.

(?<=^\d\d\d\d\d\d)\*.*$\n?

Look back to make sure we're at the beginning of a line, then match  
the line with the optional newline after.



More information about the textmate mailing list