A Notepad++ function list for MATLAB

Notepad++ is a free and open source code editor running in MS Windows. It has been around since 2003 and it's still under development. There is a long list of user contributed Plugins and an active community. Compared to the Matlab editor it's fast.

I regard Notepad++ as a useful complement to the editor of Matlab. I use it daily to

  1. inspect large text files, e.g. data and log files. A few hundred thousand lines is no problem.
  2. search (and replace) in m-files; refactor code. It supports regular expressions.
  3. quickly approach an unknown code-base
  4. and more

Notepad++ supports many languages and it is possible for the user to customize it for more "languages" with

Notepad++ comes with built-in Syntax Highlighting for Matlab, but not Function List. This submission comprises a couple of different Function List definitions for Matlab.

Contents

Submission

This submission contains xml-code, <parser>-elements, which creates the content displayed in the Function List. There are four files, functionListMatlabNameStrict.xml, functionListMatlabSignatureStrict.xml, functionListMatlabName.xml and functionListMatlabSignature.xml, each of which contains one <parser>-element. The four <parser>-elements differ regarding the output and the requirements on the formatting of the m-code.

A <parser>-element comprises a bunch regular expressions and Matlab code is challenging to regular expressions. I include both the "Strict" and the "less strict" files, because I've elaborated the two approaches and hope someone might be interested to see them as an exercise with regular expressions. The files are commented.

UDL_matlab2.xml provides syntax highlighting for a language, which I call matlab2. It's used to switch between showing the function name and the full function signature.

Installation

Notepad++ provides support for importing user defined languages. Perform the following three steps:

  1. In Notepad++ menu bar, click Language and select Define your language...
  2. In User Defined Language windows, click Import then open UDL_matlab2.xml
  3. Restart Notepad++

<parser>-elements shall be copy&pasted to the file, functionList.xml. The absence or presence of the file, doLocalConf.xml in the installation folder, controlls where Notepad++ looks for functionList.xml. If present, Notepad++ looks in the installation folder. If absent, Notepad++ looks in %APPDATA%\Notepad++ (use the Matlab command, getenv appdata, to find its value). In my installation, different versions of the file existed in the two folders, which caused a bit confusing. A legacy from old updates, I guess.

To install Function List, perform the following steps:

  1. Make a backup-copy of the file, functionList.xml
  2. Open the file, functionList.xml
  3. Copy&paste the content of matlab2_syntax_id.xml to the end of the <associationMap>-element of functionList.xml
  4. Copy&paste the content of functionListMatlabSignatureStrict.xml to the end of the <parsers>-element of functionList.xml
  5. Copy&paste the content of functionListMatlabNameStrict.xml to the end of the <parsers>-elements of functionList.xml
  6. Make sure that the value of id in the two <parser>-elements are matlab_syntax and matlab2_syntax, respectively.
  7. Save the file, functionList.xml
  8. Restart Notepad++

Confirm that the <parsers>-elements work

To confirm the installation, perform the following steps:

  1. Start Notepad++
  2. Open the file, aCompleteClassWithFunctionAndNested.m.
  3. Display the Function List panel, View,Function List. (It's possible to rearrange the layout by dragging panels, much like in Matlab. However, I sometimes encounter problems. )
  4. Verify that a function list with the full signature is displayed in the panel.
  5. Switch to language, matlab2, Language,matlab2. (This setting, which overtakes the extension, is honored until the file is newly opened.
  6. Reload the Function List panel content by clicking the Reload icon.
  7. Verify that a function list with names is displayed in the panel.

This file contains two nested function, which show up in the function list as a method and a sub-function, repectively. AFAIK, it isn't possible to show the nested function intended one level. The "less strict" <parser>elements don't show the nested functions. Neither way is perfect.