Wednesday, June 28, 2006

NAnt with SlickEdit

I'm using SlickEdit for writing NAnt .build scripts, which are essentially XML, and I'm finding SlickEdit is quite a nice XML editor.

Here's how to set it up nicely :

1) The SlickEdit completion features are wonderful - better than Visual Studio IMHO, in particular the features by-default bound to Ctrl-Shift-, and Ctrl-Shift-. and Ctrl-Shift-Space. The first two match words before and after the current cursor position. The word that is being used as the source of the completion is highlighted, and each time you press them, it moves backwards and forwards choosing a different match in your buffer. Ctrl-Shift-Space extends the match to more words following the current source word each time you press these keys.

To enable matching for any text, go to "Tools->Macro->Set Macro Variable". Enter def_complete_vars as the variable and a value of 0. This means that completion works not just for code symbols, but any text. See vslick\macros\compword.e for further info.

2) Its not well documented, but SlickEdit will provide further assistance in editing XML if it is given a schema. It works for DTDs and XSD's. NAnt's schema is given at

You have to add a URL mapping in "Tools->Options->URL Mappings". But first download the schema from above URL and save it somewhere local. Then add this URL in the From field and put your local copy in the To field.

You also need certain attribute in your document. Here is a minimal NAnt .build file that SlickEdit understands :

<?xml version="1.0" encoding="utf-8" standalone="no"?>
name = "BuildProj"
" R:\thirdparty\NAnt\schema\nant.xsd"

<target name="Build">

Do Stuff Here...


After creating this file, click the yellow XML tick on the toolbar to ensure it is "Well formed" (fix any errors). Then click the grey XML tick to check your file against the schema. I regularly get "Error Schema in has a different target namespace from the one specified in the instance document." which I have been succesfully ignoring.

Now save, close and reload this file to see the assistance features in action.

  • typing a < will show a drop down list of all the NAnt commands you could use.
  • when between the < and > it will show applicable attributes for the current tag.
  • typing </ will be completed to close the closest previous open tag.
  • recognised tags will be coloured differently to unrecognised ones.

You can also use the Project "Execute" feature and the Build shell window to run NAnt with your file.

All in all, SlickEdit makes a nice general purpose IDE.

No comments: