Takaaki Kato

Email me at comments@takaaki.me or ping me at Twitter. You can also find me on GitHub.

By Takaaki Kato

Apr 10

Working with TextMate: April 2010 Edition

TextMate is still a popular text editor for Mac. Here are my suggestions for those who are still with TextMate.

General advice for everyone

A better project drawer

First, replace your project drawer with ProjectPlus. The replacement has additional capabilities like version control status for each file. It currently supports Bazaar, Git, Subverion, Mercurial and Svk. The drawer is placed at a side where you want to have instead of having you find the drawer at a random side everytime.

Validate syntax upon saving

Second, if you edit a file, you save it. Seeing error messages and warning messages when saving a file saves a lot of time. Validate on Save bundle shows you the messages as soon as you hit ⌘S. The supported languages include Ruby, Python, PHP, SASS, HAML and JavaScript.

Working with remote files

ExpanDrive allows you to mount a remote server on your Mac. So that you can work with the files in the servers using TextMate. ExpanDrive is available for $39.95.

Working with large projects

Exclude some files and directories from search results

Searching in a project takes time when you have a lot of files in your project. One way to speed up the process is to make TextMate ignore some files and directories. If you are working with a Rails project, you could exclude vendor/rails directory from your search. You can set your search patterns at “Preferences” → “Advanced” → “Folder References”. Dr Nic shares his snippet of the pattern. If you are using Yahuda Katz’s Bundler, take a look at this Stack Overflow question.

Swiching between files with a Command-T replacement

⌘T (“Go to File …”) is quite convenient, but it’s still a bit of pain to find the right files. GoToFile tmbundle brings Jamis Buck’s Fuzzy Finder library to TextMate. A better algorithm for search, better UI, more keyboad shortcuts and more configurations. The command is assigned to ⇧⌘K.

Speed up search with ack

Another common problem for TextMate users is still about slow search. A few improvements can be done by using a bundle or a plugin. The first bundle is Ack in Project bundle. Instead of using TextMate default search, you can rely on power of ack. Ack is a command line utility like grep, which takes advantage of Perl. There is a plugin version of the bundle by the same author. It’s called AckMate. The plugin fits better in OS because it shows the results in a Cocoa window instead of TextMate HTML Preview window. If you use any of the ack tools, be aware that ack doesn’t search every file by default. Most notably HAML files are excluded from the search. Do read how to make ack to search different types of files.

Disable automatic file refresh with ReMate

The last problem I would like to address is lagging when you switch your focus from another app to TextMate. TextMate automatically refreshes files in a project when it regains the focus. For example, when you switch to a different branch in Git in Terminal and switch back to TextMate by ⌘⇥, TextMate refreshes the files in the project. If your new branch has completely different files, file contents and directory structures, TextMate needs a little time to show you the new branch. In such a case, some of you might want to disable this automatic refresh of files. ReMate prevents the automatic refresh. Both ProjectPlus and ReMare are written by Ciarán Walsh.

Working with Ruby and Ruby on Rails

Here is a list of TextMate bundles available for Ruby-related projects. This list is not exclusive, but I hope that this will get you started. Some bundles that come with TextMate itself are outdated. You need to grab the bundles for yourself.

I would suggest that you always keep looking for bundles that are actively developed. Search GitHub and be aware that most of the projects have a name “.tmbundle” at the end. Keep up-to-date with the bundles you installed.

Dr. Nic has a Twitter account dedicated for Rails bundle. Follow to get updates.

Working with JavaScript: node.js and jQuery

We all use JavaScript. JavaScript is getting more and more important as it is recognized as a server-side language. node.js bundle will be helpful for those who are learning how to node.

On a client-side, jQuery is perhaps the most popular library. jQuery bundle and jQTouch bundle save time on writing jQuery. Another remarkable tool for JavaScript is JavaScript Tools bundle created by Thomas Aylott. It has various commands such as a) validate syntax, b) compress JavaScript with Dean Edwards Packer, YUI! Compressor and Google Closure Compiler and c) validate with JSlint.

Working with PHP: WordPress and Drupal

Even if you work on Rails primarily or if you want to work on Rails exclusively, there are still many jobs around the PHP market. A blog engine, WordPress and a CMS, Drupal are by far most popular platforms on their own fields.

Some TextMate bundles help working with these two platforms. Do check out PHP Drupal bundle and WordPress bundle. They are not just a bunch of snippets, but they come with some really helpful commands. Don’t forget to read “About…” in WordPress bundle and “Help” in Drupal bundle.

Miscellaneous things you might not know about

TextMate has its own command line tool called mate. To install, visit “Help” → “Terminal Usage …”. Run mate -h to see options available. Read the section of the manual “Calling TextMate from Other Applications” for further details.

TextMate can be used when editing text areas in other apps like Mail and Safari. Install “Edit in TextMate” input manager from “TextMate” bundle. That is a bundle called “TextMate”.

Some Emacs key bindings work in TexMate as long as they don’t conflict with TextMate and its third-party bundles. Default OS X key binding can be found here. Some conflicts may happen. For example a lot of bundles assign ⌃H for help or looking up word in documentation. Ruby on Rails bundle assign ⌃P for params[...] and ⌃F for “Jump to Method Definition”. Even though this is a little annoying, you can always change the shortcuts any way you want.

I see some people on Twitter deplore the lack of column editing in TextMate. But as many others know, it does have column editing capability. Read the sections of column selections and column movement typing in the manual.

If you are overloaded with bundles or if you have bundles you never use, just hide them. You can hide any bundles, but I would highly suggest you keep “Text” bundle and “TextMate” bundle, both of which have core functions in text editing.

When you press ⇧⌘T and type some characters, the matched items available only in your scope show up. You can use capital letters if you want to run an item that is not available in your current scope.

“Filter Through Command…” (⌘⌥R) is often neglected. You can pass any command to work with your files or current selections. What this means is you can use awk, sed, grep, sort, ruby, python and even php to process text. Use the most familiar tool for you. Read the relevant section in the manual.

What percentage of the TextMate users understand the shortcuts like ⌥F2 and ⌃S? ⌃S invokes incremental search, which is often quicker than bringing up a search window. ⌥F2 shows a context menu. Now you can correct spelling errors without using a mouse. For the often ignored keyboard shortcuts, visit “List of Standard Key Bindings” in the manual.

Finally read the manual. The manual is located at http://manual.macromates.com/en/. The manual is well-written. Ask questions in the mailing list. Twitter isn’t always the best place to share your problems.


  1. read-it-later reblogged this from takaaki
  2. kenziii reblogged this from takaaki
  3. takaaki posted this