Using Notepad++’s Function List plugin for PHP development
Jan 22, 2010 PHP Coding, Web Development, Work
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&]+" 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->(.*)load->view\(['"]' regexfunc='["\/\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->(.*)load->helper\(array\(" regexfunc='[',"\w_ ]+' regexend="" bodybegin="" bodyend="" sep="" /> <Rules regexbeg='\$this->(.*)load->helper\(['"]' regexfunc='["\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->(.*)load->library\(array\(" regexfunc='[',"\w_ ]+' regexend="" bodybegin="" bodyend="" sep="" /> <Rules regexbeg='\$this->(.*)load->library\(['"]' regexfunc='["\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->(.*)load->model\(array\(" regexfunc='[',"\w_ ]+' regexend="" bodybegin="" bodyend="" sep="" /> <Rules regexbeg='\$this->(.*)load->model\(['"]' regexfunc='["\w_]+' regexend="" bodybegin="" bodyend="" sep="" /> </Group> <Group name="Include" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords=""> <Rules regexbeg='include\(['"]' 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\(['"]' 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\(['"]' 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\(['"]' 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&]+" 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->(.*)load->view\(['"]' regexfunc='["\/\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->(.*)load->helper\(array\(" regexfunc='[',"\w_ ]+' regexend="" bodybegin="" bodyend="" sep="" /> <Rules regexbeg='\$this->(.*)load->helper\(['"]' regexfunc='["\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->(.*)load->library\(array\(" regexfunc='[',"\w_ ]+' regexend="" bodybegin="" bodyend="" sep="" /> <Rules regexbeg='\$this->(.*)load->library\(['"]' regexfunc='["\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->(.*)load->model\(array\(" regexfunc='[',"\w_ ]+' regexend="" bodybegin="" bodyend="" sep="" /> <Rules regexbeg='\$this->(.*)load->model\(['"]' regexfunc='["\w_]+' regexend="" bodybegin="" bodyend="" sep="" /> </Group> <Group name="Include" subgroup="" icon="0" child="0" autoexp="4" matchcase="0" fendtobbeg="" bbegtobend="" keywords=""> <Rules regexbeg='include\(['"]' 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\(['"]' 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\(['"]' 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\(['"]' 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.
Related Posts
Tags: CodeIgniter, Coding, Function List, Notepad++, PHP, XML
February 17th, 2010 at 11:23 am
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 ?
March 12th, 2010 at 4:15 pm
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.
June 13th, 2010 at 6:09 am
Nice, but does not work – after reloading rules file becomes as it was, do not know why.
June 13th, 2010 at 6:15 am
ps. made file readonly – works now. thank you:)
June 25th, 2010 at 11:33 am
I wish I could get it to work. Function list says: no rule defined.
June 25th, 2010 at 11:43 am
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.
June 25th, 2010 at 11:59 am
Dusty, I will email you to see about resolving your issues.
June 28th, 2010 at 4:44 am
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!
June 28th, 2010 at 11:48 am
I got it figured out. My rules.xml file was located in documents&settings/user/appdata/notepad++/config
Thank you for helping, Daniel.
June 29th, 2010 at 2:17 pm
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
.
June 30th, 2010 at 1:04 pm
Dusty, take a look at my latest post: Feature request for Notepad++ Function List plugin. This should answer your comment.
July 1st, 2010 at 9:48 am
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?
July 6th, 2010 at 11:55 am
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
July 6th, 2010 at 5:22 pm
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.
July 31st, 2010 at 4:04 am
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++\
July 31st, 2010 at 4:12 am
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.