Home Download Buy Blog Forum Support

highlighting the names of typedef's C++

highlighting the names of typedef's C++

Postby miamirulz29 on Sat Apr 06, 2013 3:30 am

Currently, when you type
Code: Select all
typedef int nameInt;

nameInt is not highlighted. I would like for nameInt to be highlighted to same color as all the other types (ie, bool, int, etc.) Also, is there a way to do this with class names as well so that when you type
Code: Select all
string test;

the word string, would be highlighted. I have looked at the C.tmLanguage file, and saw that I could add string to the list of types that would be highlighted, but that would not work for other classes such as vector. There would be too many class names to add. What would the code be like to highlight class name (string, vector, cin, cout, etc.)?

Edit: Would it be possible to add a regex that would pick the last word after typedef and add that to the list of types to be highlighted?

Edit2: How come this regex is not working
Code: Select all
typedef.*?\s(\w+)\s*;
Last edited by miamirulz29 on Sat Apr 06, 2013 1:06 pm, edited 1 time in total.
miamirulz29
 
Posts: 3
Joined: Sat Apr 06, 2013 3:09 am

Re: highlighting the names of typedef's C++

Postby duncan on Sat Apr 06, 2013 11:19 am

miamirulz29 wrote:Edit2: How come this regex is not working
Code: Select all
typedef.*?\s(\w+)\s*;\



There are a lot of useful tools out there to help you get regex right.
Here's one:
http://www.regular-expressions.info/javascriptexample.html

When I removed the trailing '\' from your regex to get this 'typedef.*?\s(\w+)\s*;'
and tested it against the string 'typedef int nameInt;'
Then it reported a successful match.
Whether is was the match you wanted and whether that match produced the desired syntax highlighting result is something only you can say.

Give it a try and let us know if you have more difficulties.
duncan
 
Posts: 22
Joined: Sat Aug 27, 2011 12:59 pm

Re: highlighting the names of typedef's C++

Postby miamirulz29 on Sat Apr 06, 2013 1:07 pm

Sorry, I never had a trailing "\" when I was testing. I added it to the post by mistake. I still cannot get it to work though. Has anybody figured out how to highlight typedef names?
miamirulz29
 
Posts: 3
Joined: Sat Apr 06, 2013 3:09 am


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], reilg, Yahoo [Bot] and 24 guests