Using Notepad++’s Function List plugin for PHP development

One thing I really love about Notepad++ is the plugin’s that are available. One of such plugins that I enjoy is the Function List plugin to automatically search my code to pull classes, functions and much more into an easy to see pane on the right side of my screen. I had previously posted tutorials on another site but now I have made the process for “installing” these new rules easier by posting the XML as well as adding more features. Once you have followed the below steps the Function List plugin will show all of the following:

  • PHP classes
  • PHP class variables – (public, protected and private)
  • PHP functions – already does this by default
  • CodeIgniter Views
  • CodeIgniter Helpers
  • CodeIgniter Libraries
  • CodeIgniter Models
  • PHP include()
  • PHP include_once
  • PHP require()
  • PHP require_once()

Update: I updated the instructions based on a comment below to close Notepad++ while editing the .xml file

Step 1: Close Notepad++
Step 2: Navigate to C:\Program Files\Notepad++\plugins\Config – This is the default installation folder, it may be different on your system.
Step 3: Open the FunctionListRules.xml file in your favorite editor other than Notepad++. The settings may not save if you open this file in Notepad++.
Step 4: Do a search for the following line: (This will more than likely be at the end of the file.)

<Language name="PHP" imagelistpath="">

Step 5: Add the following code between the opening and closing Language tags:

<Group name="Classes" subgroup="Functions" icon="0" child="0" autoexp="4" matchcase="1" fendtobbeg="" bbegtobend="\{" keywords="">
            <Rules regexbeg="class" regexfunc="[\w_ ]+" regexend="" bodybegin="\{" bodyend="\}" sep="" />
        </Group>
        <Group name="Class Variables" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg="public\ " regexfunc="\$.*[^;]" regexend=".*;" bodybegin="" bodyend="" sep="" />
            <Rules regexbeg="protected\ " regexfunc="\$.*[^;]" regexend=".*;" bodybegin="" bodyend="" sep="" />
            <Rules regexbeg="private\ " regexfunc="\$.*[^;]" regexend=".*;" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="Functions" subgroup="" icon="0" child="0" autoexp="4" matchcase="1" fendtobbeg="" bbegtobend="\{" keywords="">
            <Rules regexbeg="function[\s&amp;]+" regexfunc="[\w_]+" regexend="\s*\(.*\)" bodybegin="\{" bodyend="\}" sep=";" />
        </Group>
        <Group name="CodeIgniter Views" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg='\$this-&gt;(.*)load-&gt;view\([&apos;&quot;]' regexfunc='[&quot;\/\w_ ]+' regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="CodeIgniter Helpers" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg="\$this-&gt;(.*)load-&gt;helper\(array\(" regexfunc='[&apos;,&quot;\w_ ]+' regexend="" bodybegin="" bodyend="" sep="" />
            <Rules regexbeg='\$this-&gt;(.*)load-&gt;helper\([&apos;&quot;]' regexfunc='[&quot;\w_]+' regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="CodeIgniter Libraries" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg="\$this-&gt;(.*)load-&gt;library\(array\(" regexfunc='[&apos;,&quot;\w_ ]+' regexend="" bodybegin="" bodyend="" sep="" />
            <Rules regexbeg='\$this-&gt;(.*)load-&gt;library\([&apos;&quot;]' regexfunc='[&quot;\w_]+' regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="CodeIgniter Models" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg="\$this-&gt;(.*)load-&gt;model\(array\(" regexfunc='[&apos;,&quot;\w_ ]+' regexend="" bodybegin="" bodyend="" sep="" />
            <Rules regexbeg='\$this-&gt;(.*)load-&gt;model\([&apos;&quot;]' regexfunc='[&quot;\w_]+' regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="Include" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg='include\([&apos;&quot;]' regexfunc="*.*[\w]" regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="Include Once" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg='include_once\([&apos;&quot;]' regexfunc="*.*[\w]" regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="Require" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg='require\([&apos;&quot;]' regexfunc="*.*[\w]" regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="Require Once" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg='require_once\([&apos;&quot;]' regexfunc="*.*[\w]" regexend="" bodybegin="" bodyend="" sep="" />
        </Group>

My full section including the Language tags looks like this:

<Language name="PHP" imagelistpath="">
        <CommList param1="#" param2="" />
        <CommList param1="//" param2="" />
        <CommList param1="/\*" param2="\*/" />
        <Group name="Classes" subgroup="Functions" icon="0" child="0" autoexp="4" matchcase="1" fendtobbeg="" bbegtobend="\{" keywords="">
            <Rules regexbeg="class" regexfunc="[\w_ ]+" regexend="" bodybegin="\{" bodyend="\}" sep="" />
        </Group>
        <Group name="Class Variables" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg="public\ " regexfunc="\$.*[^;]" regexend=".*;" bodybegin="" bodyend="" sep="" />
            <Rules regexbeg="protected\ " regexfunc="\$.*[^;]" regexend=".*;" bodybegin="" bodyend="" sep="" />
            <Rules regexbeg="private\ " regexfunc="\$.*[^;]" regexend=".*;" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="Functions" subgroup="" icon="0" child="0" autoexp="4" matchcase="1" fendtobbeg="" bbegtobend="\{" keywords="">
            <Rules regexbeg="function[\s&amp;]+" regexfunc="[\w_]+" regexend="\s*\(.*\)" bodybegin="\{" bodyend="\}" sep=";" />
        </Group>
        <Group name="CodeIgniter Views" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg='\$this-&gt;(.*)load-&gt;view\([&apos;&quot;]' regexfunc='[&quot;\/\w_ ]+' regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="CodeIgniter Helpers" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg="\$this-&gt;(.*)load-&gt;helper\(array\(" regexfunc='[&apos;,&quot;\w_ ]+' regexend="" bodybegin="" bodyend="" sep="" />
            <Rules regexbeg='\$this-&gt;(.*)load-&gt;helper\([&apos;&quot;]' regexfunc='[&quot;\w_]+' regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="CodeIgniter Libraries" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg="\$this-&gt;(.*)load-&gt;library\(array\(" regexfunc='[&apos;,&quot;\w_ ]+' regexend="" bodybegin="" bodyend="" sep="" />
            <Rules regexbeg='\$this-&gt;(.*)load-&gt;library\([&apos;&quot;]' regexfunc='[&quot;\w_]+' regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="CodeIgniter Models" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg="\$this-&gt;(.*)load-&gt;model\(array\(" regexfunc='[&apos;,&quot;\w_ ]+' regexend="" bodybegin="" bodyend="" sep="" />
            <Rules regexbeg='\$this-&gt;(.*)load-&gt;model\([&apos;&quot;]' regexfunc='[&quot;\w_]+' regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="Include" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg='include\([&apos;&quot;]' regexfunc="*.*[\w]" regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="Include Once" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg='include_once\([&apos;&quot;]' regexfunc="*.*[\w]" regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="Require" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg='require\([&apos;&quot;]' regexfunc="*.*[\w]" regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
        <Group name="Require Once" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg='require_once\([&apos;&quot;]' regexfunc="*.*[\w]" regexend="" bodybegin="" bodyend="" sep="" />
        </Group>
    </Language>

Step 6: Save and close, then open up a PHP file in Notepad++ to see if it shows the desired output in the Function List tool.

  • Facebook
  • Digg
  • del.icio.us
  • Google Bookmarks
  • BlinkList
  • FriendFeed
  • LinkedIn
  • MySpace
  • Slashdot
  • StumbleUpon
  • Twitter
  • Yahoo! Bookmarks
  • Add to favorites
  • email

38 Responses to “Using Notepad++’s Function List plugin for PHP development”

  1. JLuc Says:

    Super, vraiment super.

    Juste un truc : il faut ajouter un espace après “class” sinon ça choppe par exemple un appel à class_exist() comme étant une classe…

    Cela pourra t il être intégré au plugin ?


  2. Jard Says:

    Excellent! It took a while to realize I needed to switch to tree view rather then list view to see class functions. Would be nice if “Class Variables” was a subgroup of “Classes” as well.


  3. Pavel Says:

    Nice, but does not work – after reloading rules file becomes as it was, do not know why.


  4. Pavel Says:

    ps. made file readonly – works now. thank you:)


  5. Dusty Says:

    I wish I could get it to work. Function list says: no rule defined.


  6. Dusty Says:

    This looks awesome. I was just dreaming that function list would actually work like I wanted it to for PHP (hadn’t considered CI), so I googled it, and here you are.

    But, after closing npp, pasting code & saving, starting npp, opening a PHP file and function list and making sure the language was set to PHP, function list says: no rule defined.

    I re-tried pasting the code several times in case there was an error there. To be clear, this is the exact same behavior I’ve always got from function list 2.1. I did try a fresh install.

    These look like sweet features. Hope someone can help.


  7. Daniel Says:

    Dusty, I will email you to see about resolving your issues.


  8. brian Says:

    thanks! this worked great!

    for anyone else who has problems: be sure to update the xml file using something OTHER THAN NOTEPAD++. i found that if i updated it in notepad++ it would save fine, but when i closed notepad++ and reopened it to test the new settings, it would get overwritten with its old settings. apparently upon closing notepad++ over-writes plugin config settings with whatever is in memory.

    recap: completely close notepad++, open the xml file in Something Else, make your updates and save, and then open notepad++. that should do it!


  9. Dusty Says:

    I got it figured out. My rules.xml file was located in documents&settings/user/appdata/notepad++/config

    Thank you for helping, Daniel.


  10. Dusty Says:

    Hi Daniel,

    I just had a quick question – in my function list, classes are one tree base, with functions a sub-tree of an individual class, while class variables have their own separate root outside of the class list and no indication as to what class they belong to. Is that just how it has to be, or can the class variables show up as a subtree of the class they belong to?

    Not a big deal – just the difference between good enough and exactly what I want :P .


  11. Daniel Says:

    Dusty, take a look at my latest post: Feature request for Notepad++ Function List plugin. This should answer your comment.


  12. Michael Says:

    I also can’t get this working. I’m on windows 7 and found the rules.xml file in C:\Users\username\AppData\Roaming\Notepad++\plugins\config but that isn’t working either.

    When I went in to the plugin config in npp and tried to add a rule (for any language), npp crashes.

    Anyone have any ideas? :(


  13. Melvin Says:

    same problem with Michael. on Win7 changed the rules.xml file in both Program Files and Users but no go. npp crashes when i try to add a rule. help. this all sounds too good not to work. btw, i installed Function List v2.1


  14. Daniel Says:

    Michael or Melvin,
    Contact me sometime after July 12. Try contacting me on Skype sometime after 7pm Eastern time if you speak English. I will see what I can do to help you out.


  15. Francois Says:

    Hello,

    I’ve same problem than Michael & Melvin.
    What is the issue of this ?

    Windows 7, 64 bit.

    I will create some rules about interface. Never mind. Npp crash.

    path of install:
    C:\Program Files (x86)\Notepad++\


  16. Francois Says:

    I(ve found:
    if files (plgins/congif etc .. ) are copied respetcively in C:\Users\username\AppData\Roaming\Notepad++\, rules are found.
    but i cant define a new rule in editor.


  17. John Says:

    In Win7 appdata is a “Junction”. So, CLOSE NOTEPAD++ (see why previously), then Explorer to C:\Users\username then Start Run %appdata% opend “real” place. Then look for Notepad++\plugins\config and OVERWRITE bad copy of FunctionListRules.xml with good copy from ProgramFiles\Notepad++\plugins\config

    I do not understand why Notepad++ saves FunctionListRules.xml in user profile everytime it exits


  18. Evangun Says:

    I had the same problem. You have to put the file at the path François said, but also set it to read-only, otherwise Notepad++ will overwrite it everytime it launches and make it empty again.


  19. Neil Says:

    Thank you everyone. Great advice. FunctionList now operating correctly on my PC :-)

    A couple of quick notes for newbies (like me)…

    1) Even when configured correctly, FunctionList will say “No Rule Defined” until you open a file.

    2) On XP, the %APPDATA% directory everybody talks about is a folder called “Application Data” and it will be in your “Documents and Settings” folder under your username.

    Thanks again for the posts.


  20. Brandel Says:

    Hi all,

    Fantastic post + Discussion! I’m having trouble adding function listing for a custom language called “Umajin” – I try to use the language name as defined by the ‘user-defined dialoge’ (accessible under view->user-defined dialogue)- but whenever I open one of my custom-language files, who have the extension .u, it says ‘no rule defined’.

    I’ve found that the parsing rules do work on the language – when I go into the FunctionListRules.xml file and rename the language as Python, and then set the language as Python from the Language menu it works, but it means I can get highlighting _or_ function listing, but not at the same time! Has anyone got any ideas?

    (I am using win7 enterprise 64-bit, it seems like that might make a difference)


  21. Amosngweien Says:

    i am stuck at step 3 because the freaking file doesn’t even exist.
    Step 3: Open the FunctionListRules.xml file in your favorite editor other than Notepad++. The settings may not save if you open this file in Notepad++.


  22. chtquoc Says:

    1. Download function list Plugin here extract zip file. copy 3 files in zip package you extracted before into your install dir.

    2. Edit file FunctionListRules.xml. as content in “STEP 5″ by notepad and save and copy this file

    3. i am using Win 7. Start/run/ and input “%appdata%”. choose NotePad++/plugin. paste it here. and make it readonly.

    4. open file PHP and enjoin


  23. Michael Hansen Buur Says:

    Hi all,

    I have some additional rules:

    To see class variables in older php code, add:

    It would be nice if these variables would appear in list groups “Var, Public, Protected, Private” under the given class in the list. I’m not regexpert though ;)

    To see global variables add:

    I encountered some problems with comments inside class declarations, consider the following example:

    class MyClass
    {
    public $public = ‘Public’;
    private $private = ‘Private’;

    function printPrivate()
    {
    echo $this->private;
    }

    /*
    * print Public
    */

    function printPublic()
    {
    echo $this->public;
    }

    }

    The second function will not be listed. It is not just the layout of that specific comment – “/* .. */” comments inside a class in general seems to break things. I’m not sure how to fix that..


  24. Michael Hansen Buur Says:

    Darn tag stripper :-D here are the rules again (add the less/greater than chars in each line):

    To see class variables in older php code, add:
    Rules regexbeg=”var\ ” regexfunc=”\$.*[^;]” regexend=”.*;” bodybegin=”" bodyend=”" sep=”" /

    To see global variables add:
    Group name=”Global Variables” subgroup=”" icon=”0″ child=”0″ autoexp=”4″ matchcase=”0″ fendtobbeg=”" bbegtobend=”" keywords=”">
    Rules regexbeg=”global\ ” regexfunc=”\$.*[^;]” regexend=”.*;” bodybegin=”" bodyend=”" sep=”" /
    /Group
    .


  25. Mike Johnson Says:

    Hi, I am really wanting to add this plugin, but where is the actual download for the zip file?


  26. Daniel Says:

    Mike, you can download the plugin at the sourceforge.net plugin download page. Click here


  27. Malte Says:

    Hi,

    I have exactly the same problem as Brandel. I have a user-defined language called Chalice which is somewhat similar to C++. I opened the FunctionListRules.xml with some other editor, copied the language block for C++, named it Chalice, saved the XML file and started Notepad++.

    The new rules show up as expected in the Parsing Rule view, but if I press “try” nothing happens, i.e. “No Rule Defined”. In contrast, if I press “try” after selecting C++ my code gets processed as expected.

    Has anybody been able to resolve this issue?

    Thanks,
    Malte


  28. Malte Says:

    P.S.: I am running Windows 7 x64, FunctionList 2.1 UNI and the unzipped, i.e. not installed, version of Notepad 5.9.2 Unicode.


  29. Senthil Says:

    Hi,
    I have copied the FunctionListRules.xml into my notepad++/plugins/APIs or config/ folder but i can’t see the Function List tool in my Editor view.Can anyone tell me the reason.I am using windows7.

    Thanks & Regards,
    Senthil A


  30. Jordi Says:

    @Daniel, Thanks for this fantastic post!

    @Senthil, may be you need to put your FunctionListRules.xml to you %AppData% diretory, in windows 7 C:\Users\Lixas\AppData\Roaming\Notepad++\plugins\config\FunctionListRules.xml


  31. Richard Says:

    I have copied the FunctionListRules.xml into my notepad++/plugins/config/ folder but i can’t see the Function List.
    I have also added it to the C:\Users\username\AppData\Roaming\Notepad++\plugins\config\FunctionListRules.xml directory and also made them both read only

    When I run the function plugin all I get is require_once ../../includes/initialize.php

    This is at the top of the php script that I loaded into notepad++

    I have tried this over and over and still no results


  32. Daniel Says:

    @Richard, Did you close out of Notepad++ before you made the changes to the FunctionListRules.xml? What operating system are you on? Try adding a rule in the editor inside of Notepad++ and then check the FunctionListRules.xml file to see if it added it to the list or not.


  33. Konrad Says:

    Selected function background is currently in blue. When the focus is not in the function list frame, then the current function is highlighted in grey.

    Light grey background is hard to see, so I would like to change it.

    How can I change the active and inactive line background color?
    Could you put a color change possibility into config file?

    Thanks!


  34. Waschman Says:

    The plugin 1.21 does not work with Notepad++ 5.9

    I am troubleshooting this at the moment.

    Not recognizing any rules at all.

    Seems like a good plugin.


  35. Waschman Says:

    Sorry! I meant version 2.1 of the plugin


  36. Malte Says:

    @Waschman: Please let me (and others) know if you manage to get the plugin working again. That would be great!


  37. Still Says:

    RE: path for files

    Maybe this will save somebody some trouble:

    I’m running Notepad++ v5.9.3 and Function List v2.1 on Win 7 Home Premium on a x64 machine. I was having problems with this path thing but finally got Function List to list functions for my MQL4 code when i select one of the C languages. Not able to add any group or rule yet from the Parsing Rules dialogue box yet without crashing NPP. Curiously, if i try to view the results for VB, it will also crash NPP.

    Anyways, i had trouble with path till i found “Run” in Accessories and typed in %appdata% notepad++

    This revealed the path/folder to where this legendary extra FunctionListRules.xml file was located. Sure enough, it was only 1 KB instead of 33 KB. So i took someones advice and overwrote the 1 KB file with a fresh 33 KB (the size of my original file) file, and for the hell of it, changed it to read-only. Finally! I’m starting to get results. For the hell of it, i reverted it from read-only to what it was before and it seems to not be bothered when NPP opens and closes.

    Don’t make the mistake i made re: path. I manually searched for the path of this elusive appdata (in Win 7) or application data (in XP) folder by unhiding hidden folders. I first went c:\Users\default\AppData\Roaming

    …but i found no Notepad++ folder! So i made one, and also a plugin\config and put the files in there! That was a waste of time because it was a wild goose chase. I had somehow not seen there was another path that goes more like this:
    c:\Users\Owner\AppData\Roaming\Notepad++

    To see AppData folder, you have to go to Organize>Folder and search options…

    Whew!

    Now if i can just edit in some rules without crashing NPP!


  38. TenLeftFingers Says:

    Still, thank you. I’m using Windows 7 and your instructions are the ONLY ones that worked completely without the need for any extra steps.

    Many thanks!
    Ten


Switch to our mobile site