TextMate, a new editor for MacOS X, was released today.
It includes some features that (I think) are quite novel. One of these is called "triggers". Triggers allow you to type a shortcut to text that you use frequently (such as an "a href" tag), and have it expand when you hit "tab". What's special about this is that you can have variables in the triggers that allow you modify the attributes and have default attributes as well. It's a bit confusing, but I can try and demonstrate it.
For instance, I wanted a trigger to insert the text to create an NSMutableArray in Objective-C. Normally, I would have to type the following (for a generic array):
NSMutableArray *array = [[NSMutableArray alloc] init];
Typing this over and over again can become quite a chore. XCode's code-completion helps, but only completes some of the elements that make up this line.
In TextMate, I can add the following as a "snippet", to which I give the trigger "nsMA":
NSMutableArray *${1:array} = [[NSMutableArray alloc] init];
$0
So, when I want to insert that piece of code, I just type in "nsMA" and then hit "tab", and I have the original piece of code! However, what's even better is that it automatically selects the "array" part of the line, so that I can easily rename the array if I want to. This is accomplished using "parameters", of sorts, such as ${1:array}. The $1 means the first parameter, and the :array is the default placeholder.
As an example, if I wanted to have a snippet of code that create an NSMutableArray (as above) and an NSMutableDictionary, using the one "trigger", I could create the following snippet, assigned the trigger "nsT":
NSMutableArray *${1:array} = [[NSMutableArray alloc] init];
NSMutableDictionary *${2:dict} = [[NSMutableDictionary alloc] init];
$0
So, when I type in "nsT" in TextMate, and hit "tab", I end up with:
NSMutableArray *array = [[NSMutableArray alloc] init];"array" is selected, and I can enter in a different name for that. I can then hit "tab" and it will skip to "dict", which I can rename as well. Neat, huh?
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
It also automatically closes brackets, parentheses and quotes, which is handy. One other feature I like (but haven't used) is the auto-completion of words. According to the site:
"If the word Basecamp has already been mentioned in the current text, you can write "Bas" and hit escape to have the word completed. Multiple matches can be cycled through hitting escape repeatedly."
That said, it's still a bit rough around the edges. I found a bug (which I've reported) where you type in a trigger, press "tab", then undo and try another trigger, which causes a crash. There's also no way to easily change the colours for syntax highlighting (yet).
One thing I'd also like, which would convince me to use it over the editor in XCode, is code-completion. Apparently it isn't a scheduled feature, though. :-/
I'll be watching this product in the future, though, as it looks promising.
UPDATE:
Some other people who have written reviews about TextMate:
