Home Download Buy Blog Forum Support

Syntax colouring of variables

Syntax colouring of variables

Postby consequence on Mon Mar 28, 2011 8:52 pm

Hi, I am using a theme which has coloured variables and user functions in python, but this does not show up in the editor.

Does the editor not get enough context to make this possible? Or am I doing something wrong?

Thanks.
consequence
 
Posts: 3
Joined: Mon Mar 28, 2011 8:49 pm

Re: Syntax colouring of variables

Postby guillermooo on Wed Mar 30, 2011 1:18 pm

Make a note of the scope selector in the theme you're using and try to locate it in the syntax def for your language. That way you will know whether your syntax def provides enough context for your theme.

Also, note that scope selectors don't need to match exactly, so "variable.foo.bar" in a syntax def would match against a syntax def defining "variable" only.

Alternatively, switch between a couple of themes and see whether you get the highlighting you want.
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am

Re: Syntax colouring of variables

Postby consequence on Fri Apr 01, 2011 4:55 pm

Thanks for the reply.

I've tried all the themes; none of them colour variables.

The python syntax definition doesn't have plain variables. I see that it uses regexes - is it even possible to identify a variable like this?
You say "my syntax def": do people use one other than the default?

I'm not sure whether I'm asking for something that's completely impossible or whether everyone is using it.
consequence
 
Posts: 3
Joined: Mon Mar 28, 2011 8:49 pm

Re: Syntax colouring of variables

Postby guillermooo on Fri Apr 01, 2011 6:39 pm

It isn't always possible to match variables with regexes in syntax defs (which Sublime uses to create scopes, which in turn color schemes use to highlight stuff). That's the case for python; you cannot reliably tell variables apart from other tokens.

However, it works for Powershell, for instance:

https://bitbucket.org/guillermooo/power ... age#cl-266

You normally use "default" syntax defs, not customised ones, yeah, that was a manner of speaking.

More info on syntax defs:

http://sublimetext.info
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 35 guests