I have Notepad++ version 6.1.8 How can I configure it to highlight the matlab multiline comment %{ ... %} as a comment block?


I read here that this feature was added to Notepad++ in April, so I downloaded the latest Notepad++ (6.4.5) and installed it over my older 6.1 version, but it still does not highlight Matlab block comments. What should I do to get this feature working?

  • I've confirmed that block comments are not enabled in the latest changesets in the Scintilla repository. I'm having trouble getting all of the build dependencies sorted out, so it might take me a bit longer than expected. – Breakthrough Oct 23 '12 at 23:12
  • no problem please take your time and thank you showing interest – user13267 Oct 24 '12 at 0:50
  • Alright, patch submitted to the Scintilla developers. I'm having a lot of trouble compiling the Notepad++ distributed version of Scintilla though. I can compile the official one, but when I replace my SciLexer.dll with my compiled one, Notepad++'s syntax highlighting doesn't work (or rather, very few "features" do). Unless I can get the NPP version of Scintilla to compile, I'm afraid you'll have to wait until the next version of NPP (which usually has the latest version of Scintilla) to come out. – Breakthrough Oct 24 '12 at 2:05

Changing the default line in the file langs.model.xml to <Language name="matlab" ext="m" commentLine="%" commentStart="%{" commentEnd="%}"> will do the trick. But it is not going to work because notepad++ shall match the % in %{ as the start of a single line comment and not try to match it for a multiline comment. The same goes of %}

Sorry to provide you a solution that is not going to work :-/

  • So does that mean I need to do something like recompile Notepad++ to get this feature? Would doing so be feasible? – user13267 Oct 23 '12 at 2:52
  • 1
    That might help. If you change the order in which notepad++ parses the text file ( lexical analyzer / grammar). But that is not my area of expertise. – Lord Loh. Oct 23 '12 at 3:21
  • 1
    @user13267: I may also suggest that you report this to the developers. They may modify the code. This would benefit everyone and you will not have to patch and compile every version they release. – Lord Loh. Oct 23 '12 at 4:49
  • I don't have my login handy, but here's the bug report link. Same issue for CoffeeScript comment (#) vs block comment (###). – Cees Timmerman Feb 18 '16 at 16:45

Notepad++ is based on the Scintilla code editing component, so that's the part of the application you'll need to update. I had a quick look through the source code, and found that the main reason is that the LexMatlab.cxx file only contains code to handle inline comments, not block comments.

I've submitted a patch to the Scintilla SourceForge project, so it should be fixed soon with regards to Scintilla. As I mentioned in the comments, I'm having trouble compiling the Scintilla bundled with Notepad++, so unless I can get that going, you'll likely have to wait until NPP's next version is released (which should include an updated Scintilla).

  • I checked out your website at bcastell.com/tech-articles/… where you mention that this feature was added in April 2013 and so I downloaded the latest version of Notepad 6.4.4 and installed it over my older version, but it still does not highlight Matlab block comments. Do I need to do something else besides installing notepad++, to get this feature working? – user13267 Sep 10 '13 at 1:00
  • @user13267 the issue was fixed for Scintilla, which is used by Notepad++ to provide the code highlighting. It's possible that Notepad++ is still using an older (stable) version without the changes. If this is the case, you can try to compile Notepad++ yourself, substituting the included version of Scintilla with the latest source code. Alternatively, you can try just applying the patch I posted to the Scintilla SourceForge project on the version included with the Notepad++ source code and compiling it from there. – Breakthrough Sep 10 '13 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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