This morning, I was delighted to see an update for Textmate - but as I scanned the release notes, I was temporarily irked to learn the key combinations for tabbing between files had been changed. ”Tabs” are a major user interface element that makes web browsing and code editing into a more effective experience, but it’s really annoying when different programs use different keys to do the same thing. In this case, Google Chrome, Terminal.app, and TextMate have all used slightly different mappings at different times, and life would be so much easier if they were all the same. Fortunately, OS X makes it very easy to control keystroke combinations, so I quickly changed Textmate to use my familiar tab forward/backward configuration - and I’ll show you how to do this yourself.
Keyboard Shortcuts to the rescue
OS X provides an interface for mapping any key combination onto any menu item. In terms of an application like TextMate, when you see a pull-down menu option like “Next File Tab”, you can change the keys for that item to any combination you want.
Start by opening the Keyboard control in System Preferences
Then click on the Keyboard Shortcuts tab at the top of the window, then select Application Shortcuts in the left column.
Next, click on the + icon, which will enable you to create a new mapping.
In the screenshot above, it says “tell TextMate to call the Next File Tab option whenever I press a certain keyboard combination.” You can add any application you want by pulling down Application, then finding “other” at the very end of the list:
And that does the trick! TextMate behaves exactly like I want, even though they changed the key mappings with the latest release. This principle generalizes to almost any OS X application out there, with certain notable exceptions like X11 programs.
What makes a good key combination?
This is a rather philosophical question, but one framework approaching it is this: the most common commands should be the easiest to type. This property can be measured in terms of whether you can do the keystroke one-handed (e.g. cmd-s) versus two-handed (cmd-^), or in terms of how far you have to stretch your fingers to reach the keys (cmd-z versus cmd-y). I am using cmd-alt-arrow keys to control my tabs, which is a two-handed combination. I might even consider switching to something simpler, but I’m used to this combination by now, and I use the same combination in several different applications… so it’s probably here to stay.
Now that you know how to control any application, you can normalize between applications too. This process is so simple, and it can relieve so many little headaches. Enjoy!