The Hidden Magic in TextMate
By Nick Pellant
02 September 2010 | Category: Code
TextMate has become an essential part of my development arsenal over the last few years. When you first open up the application, you may be wondering what all the fuss is about- at first glance it looks like any other text editor. The true beauty of TextMate is the plethora of bundles, add-ons, keyboard shortcuts and tab triggers available. I'm going to go through some of my top tips on how to get the most from TextMate and increase your development productivity.
Tip 1: Find Your Perfect Theme
Getting yourself hooked up with the right theme is essential to a good days development. There is a huge amount out there catering for virtually every taste, so make sure to hunt around for one that’s right for you. Personally I have two themes that really hit the right spot for me:
- Clouds & Clouds Midnight – Two delightful themes especially good for the PHP developer inside you. It comes in two flavors – dark and light, both with strong bold colors that help you work on without getting dreary eyed.
- IR Black & IR White – This is my go too when I’m cracking on with some Ruby work. Again in dark and light versions with fantastic syntax colors. You’ll also find a nice terminal modification for the theme around too.
Theme choice is very much down to preference and what you’ve been used to before, so when you find the right one for you you’ll know. Make sure to search around and give a few a go, but these two are in my mind a great place to start!
Tip 2: Have the Right Plugins
TextMate comes with a great stockpile of neat features out the box but there are a few things you’ll probably think are missing. Here are a few that I’d call essential to get:
- MissingDrawer (Resurrected) – One gripe I had with TextMate from the start was the side drawer- mainly because it wasn’t a drawer at all. This plug-in solved my woes. This plug-in is a must for any serious developer.
- AckMate – As the name suggests, this allows you to run ack within TextMate. TextMate comes with a regular project search, but this is much, much faster when you just want to do a bulk find for something.
- ReMate – Now this plug-in won’t be useful to everyone, but it certainly is for me. If you work on a network mount in the office you’ll find that every time you switch in and out of TextMate your project refreshes and lags, causing you to wait a few seconds before you can do anything again. This plug-in de-activates the automatic refresh and helps save your sanity from going under!
Tip 3: Get the Best Bundles
Bundles are small add-ons that do great things. If TextMate doesn’t default support a language that you work in (HAML & SASS are prime examples) then you can be darn sure there’s a bundle for it out there somewhere. Bundles add syntax coloring, shortcuts and tab triggers to make your development as fast as it can be.
- HAML & SASS Bundles – These are perhaps the most common bundles to be installed. If you work in HAML & SASS you’ll want these badly.
- GIT Bundle – If you use GIT for your version control, then this is a bundle you can’t be without. It allows you to manage your repository from within TextMate, do blame checks and much more. There’s also an SVN Bundle if that’s more your thing.
- CSS & HTML Bundles – Although TextMate comes with some of it’s own, you’re going to want to grab the ones from Minimal Design. They add fantastic tab triggers to virtually eliminate most typing.
- jQuery Bundle – A great bundle for working with jQuery. Features tab triggers for many functions and some pretty good syntax highlighting.
Tip 4: Use those Sexy Shortcuts
This is where TextMate really comes into it’s own. You can find a shortcut for virtually any function to help you on your way to productivity success. There’s far too many to mention them all, but these are some of the key combos that I use on a daily basis.
- ⌘T – Go to File – This shortcut is truly second to none. Instead of trawling through your project drawer or going through the folders in your finder, use this to quickly jump straight to any file you wish to be in.
- ⇧⌘T – Go to Symbol – This works in the same way as Go to File but for within a specific file. Trying to find a set method or a global variable? Look no further good sir, this is what you need. Especially useful for when you’re working with a massive user model!
- ⌘L – Go to Line – If you’re debugging a stack trace, you’ll want to remember this one. Jump to an exact point within a file to squash that nasty bug!
- ⇧⌘L – Select Line – Select the entire line of code you’re working on. Chances are you may want to follow it up with…
- ⌃⌘ + ARROW – Move Code – Move the selected code around the file, helps when doing some refactoring of that nasty functional code.
- ⇧⌃⌥V – Send selected to Pastie – This one is pretty unknown but handy. Send the selected code over to Pastie with a private URL for sharing the code – great when you need some feedback from a fellow developer.
- ⌃S – Simple Search – Most folks know about ⌘F as it’s the same in most applications. However in TextMate it loads up an additional window for find and replace which isn’t always what you want. This shortcut allows you to do a quick search in the current file iteratively.
- ⌘] and ⌘[ – Block indentation – Indenting manually can be a pain – use these functions to indent blocks of code quickly and easily.
- ⇧⌃T – To-do list – This feature scans the project for code marked as ‘FIXME’, ‘TODO’ and ‘CHANGED’. It provides an informative list of them along with comments.
Make sure to do some googling for even more handy functions – if you can think of it, it’s probably there!
Tip 5: Learn your Tab Triggers
Tab triggers are for quick code completion and are invaluable to the well-trained TextMate user. For example typing doctype TAB will give you the option of inserting the appropriate doctype of your choice into your document, even HTML5 if you have that bundle installed.
The triggers are different bundle to bundle, language to language, so make sure to check out your specific bundle for more details.
Where to go From Here?
The best way to learn TextMate is to use it and explore. Try new shortcuts out, look into the gears menu and google until your hearts content.
Also, if you have something specific that you find useful in TextMate, make sure to share it in the comments. One of the best ways to learn the secrets of TextMate is from each other!
Follow @thinkvitamin on Twitter Please check out Treehouse
