Is it possible to capture the other words (the libraries) that occur on the same line, so that I might colour them differently?

However, I would be happy just to capture the whole line that begins with either import or from

Also, is it technically possible to then reference the captured library-names elsewhere in the Python file? I'm thinking that all references to the library could use the same colour that is given to them on the import/from line. [I'm thinking it's either not possible, or v.difficult ]

Andy.

"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

Is it possible to capture the other words (the libraries) that occur on the same line, so that I might colour them differently?

Also, is it technically possible to then reference the captured library-names elsewhere in the Python file? I'm thinking that all references to the library could use the same colour that is given to them on the import/from line. [I'm thinking it's either not possible, or v.difficult ]

Or you can add a new dict match for each individual package or you can just match the entire line like you said with a greedy asterisk period match (.*).You have lots of options and all the examples you should need to learn them are in the tmLanguage files.I find regex to be fun and I hope you like it too because you will need to know it well to edit these files.Also there are 11 groups you can use to scope your sytanx in Sublime which uses the TextMate scopes which are listed here:http://manual.macromates.com/en/language_grammars

These matches will work throughout the entire page.If you want to match blocks of code use begin and end keys and use patterns key for matching inside those code blocks as long as there is a well defined end match.You can also use include key to include syntax definitions inside matching code blocks.

Again play with the tmLanguage file. It's easy to check the scope you've defined by pressing ctrl+shift+alt+p

The tmLanguage files seem complicated at first but it's not too bad once you start to separate all the xml elements out.You can spread the various dict elements out so you can focus on them better. The xml tends to blend together at first.

Related to this topic I'm sort of botching the 'Python.tmLanguage' file to achieve what I'm after. The following code allows me to colour-code specific methods. However, I cannot persuade it to insist on a leading dot . before the method call. No matter how I modify it - using (?:\.) \.{1} or (?&lt;=\.) the method drops into the 'meta.function-call.python' scope.

Is there a way I can achieve this behaviour? Either by modifying my expression or the 'meta.function-call.python' equivalent expression? I would like to achieve this without having to delve into a substantial editing (begin, end, endCaptures, etc.) of the tmLanguage file.

What do you mean persuade it to insist on a leading dot? If you need this rule to absolutely always match a dot you use an escaped dot (\.)Here is a cool regex tester you can use if you want to make sure your regex is correct (someone posted earlier) http://gskinner.com/RegExr/

I'm quite/reasonably comfortable with regex. Put another way, I want the default Python.tmLanguage to capture only the word 'mycall' (and brackets) - and to require a leading dot - for the scope 'meta.function-call.python' in: