Highlighting various variable definitions... Velocity Syntax

Syntax highlighting, code folding, brace matching, code indenting, and function list

Highlighting various variable definitions... Velocity Syntax

Postby a.n.b » Fri Oct 08, 2004 5:52 am

Hello, hope someone can help me out!

I'm using the word-file for Velocity downloaded from this site.

I'm wondering if it would be possible to get several variable prefixes
highlighted.

Example:

#if($myVar == 'foo') --> $myVar is highlighted

#if($!myVar == 'foo') --> $myVar is NOT highlighted

#if(!$myVar) --> $myVar is NOT highlighted

#if(${myVar}) --> $myVar is NOT highlighted


Any help would be much appreciated!
Thanks - Alex!
User avatar
a.n.b
Newbie
 
Posts: 2
Joined: Thu Oct 07, 2004 11:00 pm

Re: Highlighting various variable definitions... Velocity Sy

Postby Mofi » Fri Oct 08, 2004 9:41 am

Never seen a velocity file, but after looking into the wordfile I know, why the first is highlighted and the rest not.

The '!', '}' and '{' are word delimiting characters defined at /Delimiters=.

In color group 4, you find the line ** $, which means, highlight all words starting with '$', which is possible because '$' is not a word delimiting character.

So the first one is OK, because this is the word "$myVar".

The second one is not highlighted, because UE interprets it as word "$" and word "myVar". The '!' is delimiting it into two words.

The third one is highlighted, because of the same reason as first one. I tested it. Have you written it correct in your post?

The last example is not highlighted, because UE interprets it as word "$" and word "myVar". The '{' is delimiting it into two words.


If you really need, that your variable is highlighted on all 4 examples, you have to remove '!', '{' and '}' from the delimiters definition and modify color 4 to:

/C4"Methods"
** !$ $ ${

Don't know, if it is a good idea to remove '!', '{' and '}' from the delimiters definition. Estimate, it isn't.

Better you add your variables to section /C4 manuelly.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4054
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Highlighting various variable definitions... Velocity Sy

Postby a.n.b » Mon Oct 11, 2004 12:29 pm

Excellent, thanks for your help - that solved my problem!

Cheers - Alex!
User avatar
a.n.b
Newbie
 
Posts: 2
Joined: Thu Oct 07, 2004 11:00 pm


Return to Syntax Highlighting