It’s Text, Mate!

Rikki has been chipping away at me for months now about a relatively new OS X text editor called “TextMate“.

I’m a long time BBEdit user. I’ve used it ever since version 5 and I’ve never coded anything in any other text editor – so it was always going to be an uphill struggle to get me to switch. BBEdit is comfortable and feels totally natural. I don’t have to think about the interface, my mouse finds its own way around.

Rikki was selling me on many of TextMate‘s features, including the “snippets” editor. This allows you to define “snippets” of text that are activated either via a hot key or via a keyword followed by a tab. TextMate comes with hundreds of pre-defined snippets, many for PHP. Not only can you define snippets of text, you can also use TextMate’s tagging system to allow you to tab through the result to change data.

For example:
You type: “array” then hit tab. It adds “$arrayName = array( ‘var’, );” to the document with ‘arrayName’ highlighted. You type in your desired variable name, hit tab and it moves to “var”, change that and hit tab and it moves to the comma, allowing you to delete it or to add more elements to the array.

I finally got around to trying out TextMate today and I’m sold. I’ve purchased a license and retired BBEdit. There are so many time-saving features: from the project display which allows you to list all your project files as a drawer (a common feature to IDEs but lacking in BBEdit) to being able to create your own snippets (I have created one where you type “ips” and hit tab and it adds “$this->ipsclass->” into the document and a few for comments, functions, etc). You can also create commands which can run bash / perl scripts. I have one that takes the highlighted text and runs it as a query on my test IP.D database.

It’s also very, very quick unlike most IDEs I’ve tried. There is no lag when typing and apart from a few seconds for the syntax colouring to kick in when loading a new document (you are free to edit and move around the document while it thinks about the colours, it doesn’t lock up the computer) everthing is instant.

I took a quick movie capture of it in use. Notice how the mouse doesn’t move until I double click on ‘require’ to show off the “Get Document for Word” feature (I set that to F3). The function block illustrates the ability to tab through the snippet elements. Sorry about the dodgy quality and the dark gray banding across the first fifth of the window.

It took me a while, but I got there in the end It really does speed up coding, and allows you to do pretty much whatever you want in your code. You can write commands to do anything using any language that you can access via Shell. You can launch apps using shell commands. You can run text from any document through PHP using shell. You can even run applescript through shell to do whatever you need.

Right now I can type a query in any document I have open, select it, hit F4 and it pops up a window with the results of the query. You can do all your SVN checking in and out and updates via hotkeys. It’s so customizable it’s untrue.

(Can you see what Matt’s had to put up with for the past couple of months now?)

Cool, I’ve been trying out TM for a little while too. I still switch between it and BBEdit from time-to-time, but I’m starting to like TM more. What you need to do is start using expandable snippets for your comments. I noticed in your video you had to separately type in your comments. Well, try popping in this snippet:

I linked that to “com” and tab under the Source group in the snippet editor. So, I type com, hit tab, and type in my comment. The top and bottom dash lines will automatically expand to fit the text I type. It’s cool stuff.

Which features would you say are innovative? From what I’ve read and seen of TextMate, it dosn’t have anything that a lot of other editors have. Although I would have to say that is implemented those features in very slick ways, better than a lot of other implementations I’ve seen.

I wouldn’t see how the app has innovative features. The only thing that it could have that is unique is the drawer and the array->tab->[automatic]phpcode, but that seriously couldn’t be that hard to impliment.

If someone made a TextMate for Windows I would definately buy it, but not for the Mac; at least, not yet. From what I’ve seen, it wouldn’t be too hard at all to make an editor like that, depending on your knowledge of any given language.

Agreed on TextMate. I bought a Mac Mini to play around with OS X. I had no idea TM existed before I bought it. I found it my second day of using OS X, and I paid for the license on the third day. Now it’s the only thing I develop on, I love it.

TextMate is certainly great, but surely there are more exciting features than snippets – Java IDEs have had this sort of things for 3 or 4 years now. If you want to see the state of the art in IDEs, check out IntelliJ IDEA. Unfortunately it doesn’t do PHP…

Surprisingly, PHP is really lacking as far as IDEs go despite its popularity.

I love TextMate. One of the best features, that no one has seemed to mention, is the validation. It has increbile validation tools. The XML validation is a godsend. I am surprised how well it works with newer languages like XHTML and XML.