Notepad++: How to Make the Function List work with Tcl and Bash

In another post about Notepad++ I critisized that its function list feature does not work for Tcl and Bash scripts. Now I’ve got a solution. Here is it.

How to Make the Function List Work for Tcl

Open functionList.xml in an editor.  FunctionList.xml is in %APPDATA%\notepad++ or in the installation directory of Notepad++.
Add this line to the section with all the other association-entries.

 <association langID="29" id="tcl_procedure"/>

Add this to the section <parsers>

<parser id="tcl_procedure" displayName="Tcl source" commentExpr="(#)">
    <function
            mainExpr="^[\t ]*((proc)[\s]+)[^\n]+\{"
            displayMode="$functionName">
        <functionName>
            <nameExpr expr="[\w: ]+ \{.*\}"/>
        </functionName>
    </function>
</parser>

Restart Notepad++. Credits for the solution go to Detlef of compgroups.net/comp.lang.tcl. I’ve copied his’ and shortened it a bit. And added support for bash.

How to Make the Function List Work for Bash

In functionList.xml add this line to the section with all the other association-entries.

 <association langID="26" id="bash_function"/>

Add this to the section <parsers>

<parser id="bash_function" displayName="Bash" commentExpr="(#)">
    <function
            mainExpr="^[\t ]*((function)[\s]+)[^\n]+"
            displayMode="$functionName">
        <functionName>
            <nameExpr expr="[\w: ]+"/>
        </functionName>
    </function>
</parser>

Restart Notepad++.

Download

Or just download my functionList.xml with Tcl and Bash support and replace yours.

Effektiv Tcl/Tk programmieren . (Programmer’s Choice)

Update: As Olivier from comp.lang.tcl pointed out, my version does not work with Npp 6.4.3. I’ve rechecked this, he is right. My version does work at least with versions 6.4.5, 6.5 and 6.5.5, though.

Update 2: Thanks to Rasha Matt Blais for his improved version of the mainExpr for bash functions. Though that one still misses some types of function definition. Here my latest mainExpr string:

mainExpr="^[\t ]*((function)[\s]+)[^\n]+|[\w_]+[\s]*(\([\s]*\))"

I’ve also adapted the downloadable functionList.xml. And I’ve added the testfunc.bsh file which contains some bash functions with which I’ve tested the my mainExpr string.

8 thoughts on “Notepad++: How to Make the Function List work with Tcl and Bash

  1. For bash, to include both styles of function definition, use the following line:

    mainExpr=”^[\t ]*((function)[\s]+)[^\n]+|[\w_]+(\(\))”

  2. @Rasha: Thank you much for this improvement! I’ve improved your version further and updated my dowloadable functionList.xml.

  3. Thanks for this bit of code! I’ve been trying to figure out how to get Notepad to support Tcl, this is great!

  4. @Vuk : You’re welcome! It’s nice to see that I helped somebody.

  5. @RR : I have tried tcl part with NPP 6.5 but can not make it work at first. Then I noticed the functionlist.xml Andreas said to change was in AppData, not in NPP installation path. Please check whether you are making same mistake :).

Comments are closed.