Friday, April 06, 2007

TextMate - Putting the Fun back in Typing

I've been looking for the right programmer's text editor for a while. I have had high expectations of text editors, ever since I wrote my own IDE back in the olden days. I want lots of flexibility and a simple, elegant interface. Fast syntax coloring and massive configurability without the arcane knowledge required for things like emacs and vi.

I've looked at lots of things on Windows but never found one I liked. Source Insight is nice for indexing but it feels cluttered and non-intuitive. The UI looks grungy too and only part of that is the fact that it tries to use Windows common controls. Visual Studio has a nice editor if (and only if) you're building in their environment. Much of its cool functionality is possible because they also compile the code and can do cool intellisense completion based on the knowledge they get from their compiler. If you are using a different build environment(like I need to) it doesn't do much more than syntax highlighting and there is lots of UI around it that just doesn't apply. I tried BBEdit and TextWrangler on the Mac and, while they are nice, they feel more focused on web development than multi-language programming.

Enter TextMate. It is also a Mac-only text editor but it has a great combination of customizability and programmability. You can create ruby, perl, shell or applescript commands that pretty much let you do anything on the text. It relies on regular expressions for a lot of the text features which, while very powerful, is very tricky and seems to involve occasional animal sacrifices but when it works, it is cool. The UI for the applications is very clean - not a pile of toolbars and UI widgets all over the place, they have maximized the space for the text but it is still possible to get to all of the funcionality very quickly and most functionality can be browsed through menus or config windows so you don't need to remember every keyboard equivalent to get going.

A lot of my programming is on Windows these days but I can now even use TextMate while doing my builds on Windows thanks to the combination of a simple little daemon app I wrote on Windows and TextMate's scriptability.

One of my favorite features is snippets. You type in a brief keyword, then hit the tab key and it will expand that text into a larger text block and it provides placeholders for text that you can then tab between and fill them in. One great example of this is the head snippet for html. All you do is type head, then hit tab and it replaces the word head with this:
<head>
<meta http-equiv="Content-type" content="text/html; ">
<title>Page Title</title>

</head>
The cursor has selected the words Page Title so you can start typing the title of the web page. Hit tab again and the cursor is below the title tag, ready for more header content. In fact, I had to use TextMate just then to convert all of the tags into entities so that blogger wouldn't think they were actual HTML. One command - W00T!

They recently released a book called TextMate: Power Editing the Mac which is a great way to get started with all of the features. My only complaint is that, while they try to explain regexp in a simple way, I think it needs more examples and samples of how to build up the expressions. Otherwise, it is a great starting point.

Apparently, the next version of TextMate will only work on Leopard, the upcoming release of MacOS X. While that's a little bit of a bummer, I am really looking forward to the new functionality that requires the updated OS.

If you're writing a bunch of code, and you can use a Mac for that coding, I highly recommend you check out TextMate!

2 comments:

Anonymous said...

If you haven't, you should also check out Visual SlickEdit (http://www.slickedit.com). It runs on both PC & Mac, and is pretty darn good.

Duffergeek said...

I looked at SlickEdit, it is certainly pretty cool. The price difference, though, is vast. While TextMate costs about $50, slickedit costs $284. I wouldn't be surprised if SlickEdit does a bunch more than TextMate but it is tough to justify that it is worth nearly 6x more...