Extending EditPlus : Making a Better PHP IDE (Integrated Development Environment)
published : 01.Jan.2004
EditPlus Introduction
Editplus is an extremely powerful text editor particularly suited for programmers working on the Windows platform, by default it supports code syntax highlighting for most major programming languages that you are likely to use; including HTML, PHP, ASP and Perl.
EditPlus has many powerful features which every programmer will need to use on a daily basis, for example:-
- Powerful search and replace functions.
- Add markers to your code, so that you can easily move around large files and projects.
- A function list window, which allows you to jump to the start point of any function or sub within your code.
- Block comment / uncomment large sections of your code.
- Spell checker.
- Customisable by adding user tools.
Its this last point which makes EditPlus so versatile as a programmers text editor. The ability to extend and customise EditPlus means you can add features which will enhance your coding productivity.
The small tutorial which follows, shows you the steps required to enhance your installation of EditPlus; by turning it into an even more powerful development environment for writing your PHP scripts. In the examples we will add support for :-
- Context sensitive help for PHP commands.
- PHP syntax checking from within EditPlus.
- Google search for selected words within the current document.
Adding context sensitive help for PHP commands
We are going add user tools to EditPlus to perform the additional functionality, but first of all you need to download a copy of the PHP Windows HTML help file in the language of your preference, and save the file to your hard disk.
With EditPlus open select the Tools menu option and pick the Configure User Tools sub menu item; this will open the preferences dialog window (screenshot) at the user tools tab.
If you have not added any tool items before then the default name will be Group 1 which doesnt mean much, so it is useful prior to adding any tools to rename the group to something meaningful e.g. PHP IDE Tools.
Now you are ready to add your first custom tool, which will be a link to the PHP Windows help file. Select the Add Tool button and a pop-up menu will display giving you the following options :-
- Program
- Help file (*.hlp)
- HTML Help file (*.chm)
- Keystroke recording
As the PHP help file has a .chm extension then you need to select the third option HTML Help file (*.chm) which will open up two additional fields within the dialog. These fields are Menu Text and File Name, for the menu text I would suggest something like PHP Help File; and then use the browse button beside the filename field to find and locate the PHP Windows help file.
After applying the change and closing the preferences dialog window, you can test the menu option to ensure it works correctly. Select the Tools menu and you will see the menu option for PHP Help File. EditPlus also assigns a keyboard short cut for speedy access, in this case ctrl+1.
This screenshot shows editing a PHP file, with the cursor highlighting the desired command; after pressing the ctrl+1 keyboard short-cut the PHP help file is loaded to the correct section for the selected command.
Adding PHP syntax checking within the Editor
Adding this feature alone will save you so much development time as you wont have to FTP your scripts to a server just to test them and find there is a simple syntax error in your script. You can use a local copy of the PHP Windows Binaries and have the results of the syntax check returned to the output window within EditPlus.
Use the Add Tool button within the Configure User Tools menu option as in the previous example. This time select Program from the pop-up menu; this will open up all the fields and options within the dialog. Enter the following details into each field accordingly :-
Menu text : PHP syntax checker
Command : c:\php\php.exe -l
Argument : $(FileName)
and tick the capture output box. (screenshot)
Substitute the command line to the exact path to your PHP.exe file; it is important to add the -l switch as this tells the PHP compiler to just test the syntax of the script.
This screenshot shows editing a simple PHP file with a deliberate mistake, you can see that the results of the syntax check are returned to the output window of EditPlus.
Adding Google Support for Highlighted Words
This feature can be useful occasionally so its worth adding, and it gives you an additional example of how EditPlus tools can be extended. Say you are working on a script and want to see if there are any tutorials on the web for using the PHP command ob_start(). You could highlight the command within your script and invoke the tool which will launch your default browser and search Google, passing over the selected word(s) from EditPlus as the search criteria.
To add Google support use the Add Tool button within the Configure User Tools menu option as in previous examples, selecting Program from the pop-up menu; this will open up all the fields and options. Enter the following details into each field appropriately :-
Menu text : PHP Google Search
Command : start
Argument : http://www.google.com/search?q=$(CurSel)
and tick the close window on exit box. (screenshot)
Conclusion
We hope this short tutorial has given you some inspiration to explore the possibilities of extending the already excellent text editor EditPlus; if you have any helpful suggestions or tips then please contact us, we would be happy to hear from you.
