Why TextMate?

Illustration for Why TextMate?

Written by Marc on 17.02.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, ↵

Editing

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.

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

  • Generate a ‘lorem ipsum’ paragraph by typing ‘lorem’ and pressing tab
  • From the command line open a folder with the ‘mate’ command
  • Inline/incremental search, activate with ⌃S and type, press the shortcut again to go to the next match
  • Close the currently open HTML tag with ⌥⌘.
  • Toggle commenting on the current line/selection with ⌘/
  • Send a selection of text to pastie or any other application that will accept text with ⌃⌥⇧V

Paste Selection Online

Bundles

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.

Add-ons

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.

Ack

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.

Jslint

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, 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 hazelnut latte and his favourite sandwich is a croque-monsieur. Follow him on Twitter: @marcroberts.

14 Responses

  1. Clipping Path

    February 21st 2010 @ 8:43 am #

    Fantastic, new thing, (about textmate) I learned from your post. thanks :-)

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

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

  4. 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/

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

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

  7. 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 [...]

  8. 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/

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

  10. Koz

    September 24th 2010 @ 10:05 pm #

    Awesome shortcuts! Thanks!

    Quick note, to bring up your TODO list it’s SHIFT-CTL-T not Apple-CTL-T.

  11. Marc

    September 29th 2010 @ 10:45 am #

    @Koz – Thanks for letting me know, I’ve updated the article accordingly.

  12. Tom

    September 29th 2010 @ 6:42 pm #

    Great article! I love TextMate.

  13. Andy Hutchins

    October 9th 2010 @ 8:50 pm #

    Very nice article. I have tried all the popular text editors for web dev like Coda, Espresso, etc. and I keep coming back to my trusty TextMate installation. It is just such a powerful tool and I keep learning more and more about all the cool things it can do. Thanks for the tips.

  14. چگونه من ۲برابر سرعت شما کد می‌نویسم « >Hormoz.

    October 29th 2010 @ 12:05 am #

    [...] در مورد این برنامه بخونید به وبلاگ جِفْری زِلدمَن و یا اینجا سر بزنید.  از اونجایی که E-texteditor هم از امکانات و معماری [...]

Leave a Reply


(Never published)


© 2010 Neutron Creations Ltd. Registered in England #6734162.

Say: hello@neutroncreations.com