Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using Notepad++ to edit MATLAB .m files. It works well in most respects, except that it seems that the lexer hasn't been updated to be compatible with recent version of MATLAB.

In particular, it doesn't highlight the 'classdef', 'methods' and 'properties' keywords when using MATLAB's object-oriented features. Is there a way to update the lexer, or a way to edit it myself so that it correctly highlights these keywords?

The highlighting on the keywords 'classdef' and 'properties' should be the same as the highlighting on the keyword 'end':

enter image description here

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Find your Notepad++ install directory (c:\Program Files or c:\Program Files (x86), typically). You need to edit the language definition file. There's two of them: an ansi file called lang.model.xml, and a unicode file called langs.xml. Most likely you are using the ansi file if you are based in US/Canada.

Open the file in Notepad++, it's a generic XML file and can use the XML syntax highlighting. Search the file for "matlab". This should take you to a block of similar to this:

<Language name="matlab" ext="m" commentLine="%" commentStart="" commentEnd="">
    <Keywords name="instre1">break case catch continue else elseif end for function global if otherwise persistent properties return switch try while</Keywords>
</Language>

Edit the <keywords> section to include the words you want higlhlighted (Classdef, properties, etc.).

Then save the file and restart Notepad++. The new syntax settings should take effect.

share|improve this answer
2  
Thanks for this. I actually found an alternate solution by searching on Google for "Notepad++ langs.model.xml" -- in the Style Configurator, if you select 'Matlab' in the left column and 'Instruction words' in the right column, then a keyword box appears that allows you to enter user-defined keywords. Entering 'classdef', 'properties' etc in there did the trick. –  Chris Taylor Dec 14 '11 at 16:59
    
That's definitely the easier way. I missed that when I was poking around in the Settings and thought it was only for syntax coloring. –  Scott McKinney Dec 14 '11 at 18:09
    
I tried editing lang.model.xml and restarting Notepad++, and the changes did not have any effect. Using the Style Configurator above did work. –  B Seven Mar 20 '12 at 2:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.