Sunday, June 06, 2010

Learn to use UltraEdit's Function List

UltraEdit's (v16) function list allows you modify the regular expressions used for different document types to pick out and display important aspects of a document in the function list. For example, the Function List (F8) will show methods, variables and imports a Java source file; in an XML file, it will show any tag with name=" in it. Click on any entry in the function list and it will take you there. Not as good as an IDE (e.g. Eclipse, NetBeans) that also has context menus with options relevant to the semantics of each element, but extremely useful for general purpose editing.

Still, the true power of the Function List is that you can edit the settings that define what is shown - including changing the built-ins and adding your own. By default, UltraEdit's XML function definitions (UltraEdit calls them "groups") only shows XML elements with a NAME attribute, and it displays the whole tag in the function list, including the angle brackets < > and space that appears before the tag.


(Click to enlarge.)

I want to see elements with NAME or ID attributes and I wanted to tidy up the display so as not to see leading space or the angle brackets or the contents of the tag if it fits on one line. Here is what I see now:


(Click to enlarge.)

It's easy to do. Right click on the Function List, select Configuration and modify as below.


(Click to enlarge.)

The configuration strings I am using above are *<^(*name=*"^)> and *<^(*id=*"^)>.

But wait - there's more! I am working with Alfresco XML documents right now and one of them contains alfresco-config elements that don't use NAME or ID. They have CONFIG elements, each of which has an EVALUATOR and CONDITION attribute that I would like to see in my XML function view, as per below.


(Click to enlarge.)

Again, it is pretty simple. Edit the groups as above and create a new group called Alfresco Config Evaluator, defined as <config evaluator=^("*^)>.


(Click to enlarge.)

There is a risk that if I edit any other XML document that has an element called CONFIG with an attribute called EVALUATOR I will see it, but I think it's a sufficiently specific rule. Also, the element called CONFIG must have an EVALUATOR attribute immediately afterwards or it won't get displayed, but I can live with that too.