Inside the MATLAB Desktop
September 4th, 2007
Editor syntax colors for non-M file types
I recently had a customer ask me how to make his mex files have correct syntax highlighting. He had a file type that was not specified in our default preferences. This is very easy to fix using preferences.
Here is an example. I have to edit info.xml files a lot because one of the things that I work on is the start button. But when I edit an xml file there is no syntax highlighting.

If the editor hightlights the file as html, it does a pretty good job of syntax highlighting. To make xml files syntax highlight as an html file, go to the Editor Language preference panel (File->Preferences->Editor->Language). Select “HTML” from the Language combobox.

This will open the html highlighting panel. Near the bottom of this panel is a File Extensions list that shows which files will be highlighted using this set of colors.

Click on the “Add” button and type “xml” into the dialog.

Hit OK to exit the dialog and OK to exit the preference panel.
Close the file and re-open it to see the changes.

From this point forward, all xml files will be colored as html files. You can associate any file type with M, C/C++, Java, or HTML highlighting sets.
And because I predict that you will ask, we are considering linking xml files to the html color set by default in a future release.
By
Kristin Thomas
Kristin is a developer on the MATLAB Desktop team. She works primarily on the Command Window when she is not throwing herself down a mountain on her snowboard.
9:00 am |
Posted in Editor |
Permalink |
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.
Leave a Reply
|
I often work with the RealTimeWorkshop for CodeGeneration. Therefore, I have to edit tlc (target language compiler) files from time to time. Unfortunately, there is no syntax highlighting and I don’t want to have all tlc files colored as html files.
To work around this issue I use a custom text editor… see Preferences–>Editor/Debugger–>Text editor
Maybe this is useful for others. Moreover, it would be nice if you could add a tlc color set in a future release.
We hope to support TLC soon (we’re actively working on it). Though our syntax highlighting won’t fully highlight all C code, it should really help to visually distinguish between comments, macros and C code.
Also note that we are actively working on full XML support - so hopefully you won’t need to follow these steps in the future!
-Ken
Hello Ken,
Is there any news on TLC highlighting? Can we get it as an add on for older version of Matlab ( I am working with matlab R 2007b) or should we wait till next release of matlab (R2008a).
Best regards
Mansour
Hi Mansour,
TLC Syntax highlighting will be part of the next release (R2008a) scheduled for release sometime in March (check out our release schedule here). There won’t be any way to get this new functionality in earlier releases of MATLAB, so you’ll definitely need the new version.
Let us know how it works out for you!
-Ken
@Mansour (comment 3299): R2008a has been released! The MATLAB Editor now supports syntax highlighting for TLC files. See the Real-Time Workshop 7.1 feature summary for a list of all RTW’s new features.
Check out the full release notes here.
-Ken
With regards to the editor and colors, am I the only one who can barely see the faint red right size column limit? I wish there was a way to change the color. I can barely see it and I find it very useful. Thanks.
That is an excellent point. I’ll enter an enhancement request for us to consider in a future release.
Hi,
As all the other matlab users out there who have to work with different programming languages - I would really appreciate if you could add syntax highlighting for more languages in the matlab editor. For me syntax highlighting for fortran (90 and 77), shell-scripts and make files would already very useful - so that I do not need to split my screen in parts for matlab and emacs so often :-).
Bjoern
Hi Bjoern,
We’re currently working hard to make it easier to add support for additional languages in the MATLAB Editor.
Thanks for the feedback!
-Ken