2 min read

NEdit: Syntax is Easy

Screenshot of NEdit's Syntax Highlighting
(Open the image to view full size.)

Those who know me know that I like graphical text editors, as well as some not so graphical ones. When I am not hacking away in ed(1) or leveraging Unicode to its fullest potential, I am a big fan of the NEdit text editor, which I standby as one of the best text editors for UNIX today.

One of the great things about NEdit is how deceptively simple its powerful features are. Today I want to highlight its syntax highlighting, which is stupidly simple, but remarkably usable and powerful. Above, in the screen shot, you can see a simple looking window with a lot going on. The document is a CWEB program. WEB documents represent an interesting challenge to syntax highlighters, as they need to combine three different languages into a single, readable syntax. There is the documentation language, which, in this case, is TeX, and the programming language, which, in this case, is C. These are glued together by the CWEB meta language, which consists of a series of control codes to annotate code and prose. That's three languages, with three different syntaxes, all residing in the same file.

Many editors have simple, but less capable syntax highlighters, while others have very powerful syntax highlighting, but with very little in the way of easy configuration. This makes it difficult to create, say, a CWEB syntax highlighting format that works well in an hour or so. With the simpler syntax highlighting systems, you just could not do it. With the more complex systems, you can definitely do it, but it will take a bit longer than you might have expected or wanted to spend.

NEdit, on the other hand, allowed me to create the syntax highlighting that you see in the screenshot above in a matter of an hour or so, including the time it took to get the colors the way that I wanted them. [Note: if you are interested, the color scheme is Solarized, an overhyped color scheme that actually happens to look really good on my monitor and gives me just enough contrast to be happy.] Want more? What if I told you that I was able to create that syntax highlighting within NEdit's graphical syntax highlighting control, using nothing but some regular expressions and my mouse? Yes, that's right, I was able to get this highlighting with a very simple, common spec (regular expressions) and a graphical syntax highlighting tool built in to the editor. That's one of the great things about NEdit. The GUI interface is actually useful! Unlike many graphical editors, NEdit's GUI is practical, powerful, and productive, which is more than can be said for many other editors' so called GUI, which I usually disable.

I do not have space in this article to go through all of the other great features of NEdit, but I hope that this little view into syntax highlighting will allow you to appreciate the simple elegance of a well designed editor.