jEdit Bits & Tricks

For the last few years, I've been using jEdit as my primary programming environment. While it lacks some of the project-level and "code awareness" features of a full IDE like Eclipse, I've found it to be a very powerful and easy-to-use editor, which I find more useful.

This is a place for me to share some of the customisations I use to make it even better:

Modes

A jEdit "mode" is used primarily for syntax highlighting, although a few other features such as indenting rules can also be described. The current mode of a buffer is also used to activate plugins such as the "Sidekick" structure browser and auto-completion facilities.

smarty.xml
Highlighting for the Smarty PHP templating engine; based on Mads Lie Jensen's version, and the built-in PHP mode from jEdit 4.3. Attempts to correctly highlight embedded PHP, CSS, JavaScript, etc, with and without {literal} tags.

Installation

  1. Find your jEdit settings directory: the path should be listed on the Utilities menu. Under Windows, this will usually be %USERPROFILE%\.jEdit.
  2. Copy the mode XML file to the "modes" sub-directory.
  3. Edit the catalog file in that directory to contain an entry associating the new XML file with a mode name and a file glob, e.g. <MODE NAME="smarty" FILE="smarty.xml" FILE_NAME_GLOB="*.tpl" />
  4. jEdit should pick up your new changes straight away
  5. You might want to execute these lines of BeanShell code (e.g. with the Utilities->BeanShell menu) to get tag-completion/matching on html in the templates-files if you have the XML-plugin installed
    jEdit.setProperty("mode.smarty.sidekick.parser","html");
    jEdit.setProperty("mode.smarty.xml.completion-info", "jeditresource:/XML.jar!/xml/completion/html-complete.xml");