The Smultron editor keeps getting better and better. As a long-time vi user, I've been trying Smultron on and off for a year or so. In the latest major version, an essential feature was added: the ability to filter selected text through an arbitrary command. The way this works, you go to Tools » Handle Commands » Show Commands Window, where you will find a form where commands can be defined. I have several of these, but I want to focus on just two, and I think they'll illustrate how it all fits together.
My problem is that I need to go back and forth from the classic UNIX line-oriented approach, seen in the vi editor and the *roff family of formatters, and the GUI paragraph-oriented approach. The key problem is that in the line-oriented approach, the newline character doesn't indicate the end of a paragraph, while in GUI mode, it does. The ideal solution to this is to have some way easily to convert between the two, and thanks to the selection-filtering capacity of Smultron, it is now easy to do this.
There are four relevant fields in the command-entry pane (there is a shortcut field which I'm ignoring). The two commands I'm describing here are par w79 and par w9999, and those are entered into the Name fields for each command. Note that the par command is a common UNIX command, but is not included in the OS X distribution. You can get it here or here.
I decided to name the commands using the par argument syntax: par w79 means format paragraphs so that no line is more than 79 characters long, and par w9999 means that lines can be up to 9,999 characters long, which is very long. In both cases, I checked the Inline box and specified /bin/ksh as the Interpreter. The command itself is entered in the box below. These command both have two lines:
#!/bin/ksh
par wNNN < %%s
Just replace NNN with either 79 or 9999, as needed for each command. That's it.
PARINIT='rTbgqR B=.,?_A_a Q=_s>| P=.
[robg adds: The new Handle Commands window in Smultron is a nice addition, and I've used it myself to do a bit of text processing. I haven't tested the above par tip, however.]
Mac OS X Hints
http://hints.macworld.com/article.php?story=20070609164233121