I use MacVim as my primary editor and since it uses
hjkl as arrow keys and have gotten used to
l representing left and right respectively. I prefer to use the keyboard over the trackpad (or mouse) wherever possible, so I wanted to replicate using these keys as closely as possible for working tabs.
MacVim has tabs, so what better than to start with that? In
.vimrc, I map
:map <c-h> <Esc>gT :map <c-l> <Esc>gt
OS X allows you to configure and override keyboard shortcuts for menu items for any app. In
System Preferences.app >
All Applications, I add shortcuts for
Select Previous Tab,
Previous Tab and
Show Previous Tab, assigning them all to
Ctrl-H. I add
Show Next Tab,
Next Tab and
Select Next Tab. These shortcuts cover as least Safari, Chrome, Finder, HipChat, Terminal (and iTerm).
I also add app-specific shortcuts —
Select Previous Conversation and
Select Next Conversation for Messages.app,
Previous Chat and
Next Chat for Adium.app.
With this setup, I can use
h-l as left and right when I'm editing a file in MacVim, use
Ctrl-l to switch tabs both in MacVim and in most other OS X apps.
Like this post? Follow me @hboon on Twitter.