Hi
I've just started using TextMate and I'm hugely impressed by it. My text editor requirements are not very sophisticated, I use it mostly for HTML/CSS and for processing text from time to time from databases, or transcripts of online meetings with chat clients, that kind of thing. I'm sure that I will be using TextMate for my simple AppleScript writing as well now in preference to Apple's rather basic Script Editor.
I have been using BBEdit for ages and I feel it is a very fine text editor indeed, however TextMate is a bit of genius.
Before I used BBEdit I used the Nisus Writer word processor for text editing in the classic Mac OS. Although a word processor Nisus Writer was a superb text editor and, like TextMate offered many truly unique abilities. Nisus also made a text editor called QUED/M which predated their word processor and had similar unique abilities of their word processor.
One of the truly great things about Nisus Writer and QUED/M was the non-contiguous text selection and the way in which Nisus had exploited this.
I think Nisus were the first with non-contiguous text selection but today it is quite common-place. An obvious example is Apple's TextEdit which will do non-contiguous text selection. If you are not familiar with it then you can open an TextEdit document and put it in 'rich text' mode if it is not already. Then put some text into it. Now you can select non-contiguous words in that text using command-click. Now that you have selected those words you can press command-B on your keyboard and those words will turn bold.
I'm now going to describe how Nisus exploited non-contiguous text selection and why it was so very useful.
If you imagine that you have some text which is intended for a web- site. Within the text are various book titles and you wish to surround these with the <em> tag. There is nothing at all about the words of the book titles which is similar. Well with Nisus Writer you would select the book titles non-contiguously, using command-click, then you would get out the Find dialogue and put in the Find field:
.+
In the Replace field:
<em>&<em>
(The & matching all of the Find field)
Then you invoke 'Replace in Selection' and each piece of non- contiguously selected text is now surrounded by <em> tags.
In Nisus Writer you would turn that operation into a macro and now you can apply the <em> tags to any non-contiguously selected text with great ease.
Now it gets cleverer :)
In the example above the replaced text, the book titles surrounded by <em> is still selected after the Find/Replace has been performed. This means that further GREP Find/Replace can by performed using 'Replace in Selection.
With a programme like BBEdit a search for multiple items in a file will produce a browser identifying the search results. However with Nisus Writer a search for multiple items in a file will leave them selected non-contiguously in the file. This enables you to perform a further search on those non-contiguous selections with 'Replace in Selection' again.
To give an example.
I think it is nice to have smart quotes in the displayed text in a web- site. To do this I have to use HTML entities. The actual text I have contains 'stupid' quotes, however I can create a Find/Replace that will look for the 'stupid' quotes and replace them with 'smart quote' HTML entities depending on whether they come before or after words.
The problem is that there are many 'stupid' quotes in the HTML tags for things like class="main".
What I need to do is to find the text between the HTML tags and then replace the 'stupid' quotes in that with the smart quote HTML entities.
To do this in BBEdit I created an AppleScript which has a loop. It finds the first instance of 'text between HTML tags' and then replaces 'stupid' quotes with smart quote HTML tags. Then it finds the next instance of 'text between HTML tags' and so on...
To do that required me to create quite a clunking AppleScript.
However in Nisus Writer I could do it with two simple Find/Replace operations. Because Nisus Writer had non-contiguous selection of course. I could find all the instances of 'text between HTML tags' and know that this was selected. Then I could use 'Replace in Selection' to replace all the 'stupid' quotes with smart quote HTML entities. For Nisus Writer this was an absolutely trivial matter.
So, the moral of my story is that in a text editor with GREP Find/ Replace having non-contiguous text selection brings a massive amount of additional text editing power.
Patrick