Tutorial :Is there an Xcode syntax colouring for Rails, Ruby, Erb? If not, how can I write one myself?



Question:

Xcode's syntax colouring is poor at best and textmate's looks great, but I like Xcode, since I program in C++, too. I'd like to keep everything in one place and take advantage of other Xcode features.

Has anyone already done this or is there an easy way to do it?


Solution:1

You can go to Editor>Syntax Coloring>Check HTML and do it again for Ruby


Solution:2

After some googling, it looks like there is indeed some support for ERB files in XCode. It's a little hidden, though.

Check this page out: ERB Highlighting. In brief, XCode is looking for .rhtml files instead of .erb files, so .erb files don't trigger the ERB syntax highlighting. The solution, then, is to go open

/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Versions/A/Resources/Standard file types.pbfilespec

look for the mapping for rhtml:

Extensions = (shtml, jsp, rhtml);

And add erb to the list:

Extensions = (shtml, jsp, rhtml, erb);

Viola! Just restart XCode and you'll get erb syntax highlighting. There's probably a way to do it from within XCode itself, but I haven't found it yet.


Solution:3

Xcode can do custom syntax coloring, you need two files

  • pbfilespec: specifies MIME type, extension and some meta info
  • xclangspec: which holds identifiers etc. that need colouring

and put them somewhere in ~/Library/Application Support/..

I'm a Textmate user myself, so don't know if such a thing exists for ruby, and neither a more exact specification for those files, but examples for other languages can easily be found.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »