Configuring Jedit

Last modified: November 4, 2007 - 17:00

Jedit "is a mature programmer's text editor" with support for lots of programming language and text file formats, and many plugins to extend its capabilities. It is written in Java making it available across various platforms.

Out of the box it supports editing files related to Drupal including PHP, HTML and XML.

To meet the Drupal coding guidelines make the following settings in Global Options 1) Click on Editing, 2) Under "PHP": Click 'Default Settings' (to turn that off), set tab width and indent width to '2', and to use soft tabs. Do the same for Javascript and HTML.

I find it helpful to turn on line numbering in the gutter. While having the Global Options menu open, click on 'Gutter' and select line numbering.

In the Global Options section, 'General', an important option is the default line separator. It should probably be set to Unix (using '\n').

There are some useful plugin's to install. Install plugins is done from the Plugin Manager (Plugins menu) and click on the Install section. It shows you the list of available plugins and you can select them as desired.

FTP lets you treat files on FTP or SFTP servers as if they were part of the file system. Once this is installed, choose Open File and under plugins see FTP and that it has two choices Connect to FTP server and Connect to SFTP server. Fill in your user name and password as appropriate and away you go.

The plugins include jEditCVS and SVNplugin for interfacing with source code repositories.

Two plugins interface with database servers, DBTerminal and SQL.

PHPParser adds additional PHP editing features beyond syntax coloring.

Plugin configuration

John Morahan - May 11, 2008 - 00:29

PHP Parser

If you use the PHP Parser plugin, there are a few configuration options that you might want to change to make it work better with Drupal's coding standards. Go to Plugins > Plugin Options... > PHP Parser and make the following changes:

  • Enable PHP 5 support
  • Enable the warning when '<?' is used instead of '<?php'
  • Disable the warning when the final closing '?>' is omitted

I also like to enable most of the other optional warnings, with the exception of 'unused parameters' which are quite common with Drupal's hook and theme systems and don't warrant a warning.

Text Filter

The Coder module includes a standalone script named coder_format.php which you can run on your code files to format them according to the Drupal coding standards. You can use this to reformat code directly from within jEdit. There's a plugin called Text Filter which allows you to pass the contents of an edit buffer through any command, and capture the output. The coder_format script doesn't handle its input and output in the way Text Filter expects, but this is easily solved by creating a tiny wrapper script:

<?php
 
require_once realpath(dirname($_SERVER['PHP_SELF'])) .'/coder_format.php';
  echo
coder_format_string_all(file_get_contents('php://stdin'));
?>

Save this script in the coder/scripts/coder_format directory. Then in jEdit, select Plugins > Text Filter > Create new filter from the menu. Enter an action name for the filter (e.g. "Coder"), and in the Command box, enter the full path to your PHP executable followed by the full path to the wrapper script above. I also prefer to change the Destination to "Replace", but that's up to you. Click "Create" to create the filter.

Now you should have a new menu item, Plugins > Text Filter > Coder, which will attempt to format the current buffer according to the Drupal coding standards.

 
 

Drupal is a registered trademark of Dries Buytaert.