Wednesday, June 28, 2006

SlickEdit - Mouse Free Development

I use SlickEdit whenever I can for all hardcore editing tasks, including C#, NAnt and batch files. I still go to Visual Studio for debugging and Forms design.
SlickEdit is not a good choice if you're trying to save cash, but for someone like me that codes all day, its simply the best IMHO.

I don't use its ability to load VS projects. I create my own SlickEdit workspaces and projects, and in the Project tools I call a actions.bat file with arguments such as /build and /run.
"actions /build" calls NAnt with the task.
Then I have key shortcuts to launch builds. SlickEdit provides Ctrl-Shift-Up/Down arrow to skip between error locations as reported by most compilers.
I do most development using a modified NUnit runner, and runtime progress is reported in a XML file that appears in Slickedit after a run.

All up, I can edit, compile, fix errors and run without leaving slickedit or touching the mouse.

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 http://nant.sf.net/release/0.85-rc4/nant.xsd.

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"?>
<project
name = "BuildProj"
basedir=
"."
xmlns=
"http://nant.sf.net/release/0.85-rc4/nant.xsd"
xmlns:nant=
"http://nant.sf.net/release/0.85-rc4/nant.xsd"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://nant.sf.net/release/0.85-rc4/nant.xsd R:\thirdparty\NAnt\schema\nant.xsd"
xsi:noNamespaceSchemaLocation="http://nant.sf.net/release/0.85-rc4/nant.xsd">



<target name="Build">

Do Stuff Here...


</target>
</project>


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 http://nant.sf.net/release/0.85-rc4/nant.xsd 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.