Skip to Main Content Skip to Search
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

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.

9 Responses to “Editor syntax colors for non-M file types”

  1. impf replied on :

    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.

  2. Ken replied on :

    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

  3. Mansour replied on :

    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

  4. Ken replied on :

    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

  5. Ken replied on :

    @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

  6. hUser replied on :

    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.

  7. Michael Katz replied on :

    That is an excellent point. I’ll enter an enhancement request for us to consider in a future release.

  8. Bjoern replied on :

    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

  9. Ken replied on :

    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

Leave a Reply


Inside the MATLAB Desktop is written by the MATLAB Interface teams.

Team picture
  • Ken: Hi Bjoern, We’re currently working hard to make it easier to add support for additional languages in the...
  • Bjoern: Hi, As all the other matlab users out there who have to work with different programming languages - I would...
  • Mike: bswang, Depending on where your data is coming from, it may not be available from your standalone program (e.g....
  • Ken: Hi Han, Thats an interesting idea, one also present in Xcode via the #pragma mark token. There’s a school...
  • Han Geerligs: Hello Ken, how about introducing the “region” concept as used in the Visual Studio...
  • bswang: I use a uitable in guide. The uitable works well on the matlab environment. But when i build the mytest.m...
  • Jennifer French: Hi Stephen, Thanks for posting about dataset. Its great to hear about techniques that work well for...
  • Jennifer French: Hi Quan, Thanks for sharing those techniques for working with excel! They sound quite useful and...
  • Ken: @Steven: Thanks for the great feedback! We’d love to hear more about how you use the dataset function when...
  • Ken: @Quan: xlsread is a great function! Also, I like your cut and paste technique.

These postings are the author's and don't necessarily represent the opinions of The MathWorks.

Related Topics