The Particle Lab

Illustration for Why TextMate?

Why TextMate?

By Marc, 17 Feb 2010

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 Management

Lets 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.

Go To File

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.

var 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.

Column Selection

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

Paste Selection Online


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

TextMate TODO

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).

Math Bundle

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.

Is that it?

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
Photo of Marc Roberts, who wrote this blog post

Marc Roberts is Principal & Co-Founder at Neutron Creations, where he rules over all web development and technical direction. His favourite drink is a sweet manhattan and his favourite sandwich is a croque-monsieur. For a plethora of miscellany follow Marc Roberts on twitter.

comments powered by Disqus