? tweets | tweet this
I’m often asked “what text editor do you use?”, and I respond TextMate. I’m usually then asked “so, why do you use TextMate?”. There’s many reasons I use it, and I’ve heard of developers switching from a PC to a Mac in order to use it. Can a text editor be so good that it can make a developer switch operating systems? Hopefully this article will introduce you to how powerful TextMate is and you can decide for yourself.
File ManagementLets start at the beginning with file management. As with most IDEs you have a list of files and/or folders, and TextMate is no different. This is displayed in the ‘Project Drawer’ (see right). This in itself is nothing special, anyone who has used or seen OSX knows that many apps have these ‘drawers’. What is special about TextMate, at least for me, is that there is a much faster way of finding the files you want called ‘Go to file’, found under the ‘Navigation’ menu or on the keyboard shortcut ⌘T. This brings up a small dialog window listing all the files in the current project which is filtered as you type. As you can see from the screenshot below, this not only searches for exact matches but also any filename that contains the letters you enter in that order.

You can scroll through this list with the arrow keys (the first one is selected by default) and select a file to open with the enter key. TextMate will remember which files you have chosen for each entry and weight its list accordingly which allows you to create shortcuts to certain files, for example in nearly all of my Ruby on Rails projects entering ‘rou’ will select the ‘config/routes.rb’ file which has gotten me in to the habit of bringing up the routes file with the following keystrokes ⌘T, R, O, U, ↵
Once you have open the file you want to edit there are numerous ways TextMate can help you get things done quickly. One of my favourite is the ability to edit multiple lines at the same time. For example if you had the following code in your project somewhere and wanted to shorten the name of the variables.
1 2 3 4 | var Button_Next = $('button.next'), Button_Prev = $('button.prev'), Button_Cancel = $('button.cancel'), Button_Finish = $('button.finish'); |
You could use find/replace to replace ‘Button_’ with ‘btn’, or you could use TextMate’s column selection, hold ⌥ while selecting with the mouse, to select all those columns and overwrite them with ‘btn’ by typing normally.

How many times have you found yourself omitting line-termination semicolons in a language that requires them (JavaScript, Java, PHP, C etc) after a long period of coding in a language that doesn’t (Ruby, Python etc)? TextMate has a great feature which you’ll find very useful called ‘Edit Each Line in Selection’ found under the ‘Text’ menu or the shortcut ⌥⌘A. Select the text, press the shortcut and then add a semicolon, TextMate will add that character the end of all lines in your selection. Voila!
Here’s a few more quick time savers

Most of the functionality of TextMate is provided by Bundles. These are extensions that add coding snippets, language support or interfaces to command line scripts. TextMate itself comes with over thirty of these bundles supporting a wide variety of programming languages and other features. Most are specific to a particular programming language, but some of them are more general.
The TODO bundle has just one command ‘Show TODO List’ ⌘⌃T which scans through all your project files and displays all TODO, FIXME and CHANGED notes in your code with links to the lines within those files. These tags are customisable in the bundle configuration through regular expressions

The Math bundle allows you to do quick and simple calculations or base conversions (Dec, Hex & Oct). There’s just one shortcut to remember – ⌃⇧C. Select some text and press the shortcut keys, this will then present you with the following menu allowing you to select what you want to do with the selected maths expression. Option 2 (Evaluate and Replace Expression) is extremely useful for replacing inline expressions (ie, 60*60*24) with their evaluated value (86400).

The Blogging bundle allows you to edit blog posts in most blog engines that support the MetaWeblog API, including Wordpress, Movable Type, Drupal and Typo among others. There’s a great screencast over on the TextMate blog that covers using this bundle.
As well as these built-in bundles there are a number of third party bundles which can increase your productivity. Just drop any of these .tmbundle packages in to your ~/Library/Application Support/TextMate/Bundles directory.
The Ack in project bundle provides just one feature, with the schortcut ⇧⌘A, a GUI to the ack command. Ack is much like grep but is aware of programming languages and the files associated with them, so it won’t waste time searching through log files, core dumps or any other files not related to the project.

The Javascript Tools bundle provides a quick way to run Douglas Crockford’s excellent JSLint on your javascript code. By default this runs validation when you save a javascript file with the keyboard shortcut ⌘S and provides error/warning counts in a small tooltip. It also has a more thorough validation summary available on this shortcut, ⌃⇧V.
![]()
This Git bundle adds a great simple menu on the ⌃⇧G shortcut for working with git repos. You’re all using git right ?
Finally the Zen Coding bundles (Zen CSS & Zen HTML) add loads and loads of snippets to make working with CSS/HTML much quicker. Paul Boag gives a nice review of this over on the boagworld website.
If you have any must-have bundles, please drop a link to them in the comments and I’ll check them out.
These are only the features that I use regularly without looking up and just touch the surface of what is possible with TextMate. If you want to find out more about what you can do with TextMate I’d highly recommend “TextMate: Power Editing for the Mac” by James Edward Gray II (buy it from amazon). It has almost 200 pages of great information, including expert features such as creating your own bundles.
As always if you have any thoughts or criticism, either positive or negative, please leave a message in the comments.
Photo credit: batega
Clipping Path
February 21st 2010 @ 8:43 am #
Fantastic, new thing, (about textmate) I learned from your post. thanks :-)
Ivan
February 21st 2010 @ 5:21 pm #
How do you work around single character undo? I’ve used to work with editors that have chunk undo and feel like this is a big disadvantage for TextMate.
Marc
February 22nd 2010 @ 2:12 pm #
@Ivan – Single character undo is one of the downsides of TextMate, although my key repeat rate is quite high so I don’t find it too bad
Aslam Najeebdeen
February 25th 2010 @ 6:14 am #
Nice post!
I’m a hardcore Textmate user too. :)
If anyone looking forward a uniform drawer for Textmate you should check out
http://code.google.com/p/textmate-missingdrawer/
Nick
March 2nd 2010 @ 11:36 am #
Missing Drawer is discountinued by now, use Project Plus: http://ciaranwal.sh/2008/08/05/textmate-plug-in-projectplus what I also like about it are SVN badges, so you can quickly glance what you’ve changed in project.
dale
March 5th 2010 @ 9:56 pm #
I’ve actually used the windows version of textmate – e text editor (though not the latest one) – and have actually found it better than textmate itself
Float Solutions - Bringing Content Closer to Design
March 16th 2010 @ 6:26 pm #
[...] lovely little bundles are super great. They provide a ton of functionality at the press of a key. Why TestMate? over at Neutron Creations does a great job of going over some of the great bundles that are [...]
Aidan McQuay
March 16th 2010 @ 6:29 pm #
Loved the post!
I was inspired by it to do a E TextEditor post of a similar vain. I agree with Dale that it has a couple things that make it a little better than TextMate. If you ever find yourself on Windows be sure to check it out:
http://floatsolutions.com/blog/2010/03/why-i-use-e-texteditor/
Geert De Deckere
March 19th 2010 @ 7:18 pm #
Good post. Learned a few new tricks. Two other shortcuts I use all the time:
⌃⇧D to duplicate the current line.
⌃⇧K to delete the current line.