TextMate is not just a text editor for Mac OS X, it’s ‘the’ text editor for Mac OS X. Or at least if you believe the hype. Created by self-confessed UNIX geek, Allan Odgaard, TextMate has quickly risen to the top spot when it comes to Mac editors and now enjoys a somewhat charmed life in the glow of developers the world over. So the question is, what makes TextMate so special? Let’s have a look.
Generally speaking there are two reasons why TextMate has been able to push so many people’s buttons. Firstly, common conventions are elegantly handled by TextMate’s intuitive interface. In short, the software does a lot of things for you without getting in the way. Secondly, when you open TextMate you’ll notice it consists of a window and a standard Mac OS menu. The UI is certainly simple to look at. There are barely any icons or visible features at all. Yet underneath this there are so many features packed in that it is comparable to any other fully-featured text editor. You could say that its simplicity embodies David Heinemeier Hansson’s mantra, ‘convention over configuration’.
There are quite a few features TextMate that undoubtedly increase your productivity but yet are easily missed. Column Selections is one of them.
If you press alt, the mouse pointer turns into a cross. You can use this to select rectangular regions. This particular feature is very useful when editing HTML. For example, you may wish to add a
<div> around a group of elements. To keep your indentation, hold alt, click, and drag down in a straight line. At this point, whatever you do will be multiplied on each selected line.
Quick access from the terminal: mate .
This is a great feature for those who came to Mac OS from a UNIX background. And it certainly makes your life easier. To use it, navigate to where your codeÃ¢â‚¬â„¢s directory is in the terminal, then type:
This opens a TextMate instance with a project containing all the files in the directory you specified, and its subdirectories.
To set up the command line tool, go to Help Ã¢â€ â€™ Terminal UsageÃ¢â‚¬Â¦ from within TextMate.
Find in Project (cmd-shift-f)
This feature will come into its own during an intense re-factoring session. ‘Find in Project’ enables you to search through every file in the project for a pattern. You can enter regular expressions and replace text from the same dialog.
Search for a file faster using cmd-t
We think this feature will single-handedly be responsible for the most significant increase in your productivity once you start using TextMate. Press cmd-t to open a window that enables you to search, in real time, for any file in the project. Any letter you enter is matched, so you donÃ¢â‚¬â„¢t need to enter Ã¢â‚¬â„¢controllerÃ¢â‚¬â„¢ to find every controller in your Rails project. Like the others this feature is simple but immensely useful.
Bundles are basically collections of macros (these are called bundle items). Press ctrl-escape to bring up the bundle menu. Your current language (if applicable) will be selected from the list, and then you can easily use the keyboard to select the macro you want to use. For example, when writing PHP code you may often use this to type the names of the predefined variables, such as
$_REQUEST['variable']. With this example, TextMate will automatically select Ã¢â‚¬ËœvariableÃ¢â‚¬â„¢ for you, so you can enter the variable you wanted with little effort.
Another way to access bundles is to use tab triggers. With tab triggers just type the trigger and then press tab (as in the example below). The trigger is replaced with the bundle item text. Using the previous example, you can type
$_ and then press tab to bring up a list of PHPÃ¢â‚¬â„¢s predefined variables.
Even if you’re the type of person who would normally shy away from creating bundles and adding snippets, donÃ¢â‚¬â„¢t worry, TextMate makes it easy. Go to Window Ã¢â€ â€™ Show Bundle Editor. If you open up a bundle from the list, youÃ¢â‚¬â„¢ll notice several icons next to the names of the bundle items. These icons represent the types of bundle items you can add:
- Commands Ã¢â‚¬â€œ use scripts to do various things in TextMate, including: replacing text, inserting text and showing tooltips
- Drag Commands Ã¢â‚¬â€œ helps TextMate handle you dragging something into the editor
- Languages Ã¢â‚¬â€œ helps TextMate work with a given language or document type
- Snippets Ã¢â‚¬â€œ pieces of text to include into your document, including: code to run at the insertion time and TextMate variables (such as selected text)
- Templates Ã¢â‚¬â€œ use shell commands to generate new files based on a template
- Preferences Ã¢â‚¬â€œ helps the editor adapt when different settings are required for the current file type
We found it was best to start adding snippets for your common coding tasks. This helps you get used to working with bundles. TextMateÃ¢â‚¬â„¢s help section has all the information you need to create bundle items, including the syntax for snippets. Just click on the question mark after youÃ¢â‚¬â„¢ve created a new snippet to find out more (see the example below)
You may want to use TextMate to write weblog entries. Many weblogs and content management systems generally use Textile, so itÃ¢â‚¬â„¢s nice to be able to
preview Textile before inserting the text. To do this, select Textile
from the bundles menu. ThereÃ¢â‚¬â„¢s also a shortcut key set up for this bundle: ctrl-alt-cmd-p. However, you must have Textile selected as your language to use the shortcut.
TextMate also has bundles that help with version control. Many people use
Subversion, so the TextMate Subversion bundles menu is obviously very useful. You can commit changes and view diffs with very easy to read syntax highlighting. All of which will add to your productivity.
The software also has support for traditional macros and in true TextMate fashion they are extremely easy to use. You can activate and save a macro by pressing alt-cmd-m. Then, to replace the macro you just created, press cmd-shift-m. You can save the macro to the Bundle Editor by pressing ctrl-cmd-m and to view the available options for macros, look under the Automation menu.
What’s the downside?
We’ve talked a lot about what’s great with TextMate, but in which areas does it fall down and where can it be improved upon? There’s a few interface issues: it doesn’t handle lots of tabs very well and the distinction between macros and bundles confuses new users. Undo behaves differently to many popular editors Ã¢â‚¬â€ when you press undo it reverts changes letter by letter, rather than a set of changes. Many editors for Windows and Mac OS support FTP and SFTP, but TextMate only does through another FTP client (Personally, I use Panic’s Transmit.) This could make using TextMate awkward for you if you’re used to having this feature.
If you’re using TextMate to access files on a remote filesystem, there’s a few glitches that occur: TextMate can stick as it polls the remove files when you bring it into focus. This can unexpectedly change the position of the files in the project draw. Finally, there’s no way to search for text within a directory, you can only search an open file or across the entire project. Project searching works 90% of the time, but can produce too many results for a large project.
Community, support and themes
Certainly one of the ways in which TextMate has captured the community’s imagination is through its support of plugins and themes. You can easily change the software’s behavior or color-scheme which is if you want to personalise your prefered working environment and workflow quirks. Another boon is the TextMate community and wiki which are good places to find plugins and themes, as well as the User Submitted Themes list.
TextMate also works with many popular Mac OS X applications.
For example often you may need to login quickly to a server and change a script. In this case you would open Transmit, ctrl-click a file and select Ã¢â‚¬ËœEdit with TextMate.Ã¢â‚¬â„¢ This opens the file in TextMate and automatically uploads the changes when your save it.
Another thing that sets TextMate apart from its rivals is its promptness in replying to support e-mails. When writing this review we emailed the support team with a query about how TextMate handles Mac OS XÃ¢â‚¬â„¢s remote volumes, and they promptly responded. Generally, itÃ¢â‚¬â„¢s rare to encounter this level of support with online software.
In conclusion it’s clear thatTextMate does deserve the applause it has been getting from certain camps. And once it has perfected the handling of tabs and working with remote files, it will be nigh-on perfect.