Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've recently started using a Mac (running Lion), and there is one inconsistency that's getting to me.

In Chrome and MVim, I can switch tabs with Ctrl+PageUp/PageDown. But, in the Terminal, I have to use Cmd+Shift+Left/Right.

I'd like to change the latter to Ctrl+PageUp/PageDown, but I can't seem to do this.

When I go into System Preferences → Keyboard → Keyboard Shortcuts → Application Shortcuts, and add a shortcut to Terminal's "Select Next Tab", I can set it to be pretty much anything as long as it does not include a PageUp/PageDown key.

Why is there such a limitation, and can I get around it?

share|improve this question

migrated from Sep 10 '11 at 5:38

This question came from our site for system and network administrators.

up vote 6 down vote accepted

defaults write -g NSUserKeyEquivalents -dict-add "Select Previous Tab" "^\UF72C" "Previous Tab" "^\UF72C" "Previous Workspace" "^\UF72C" "Select Next Tab" "^\UF72D" "Next Tab" "^\UF72D" "Next Workspace" "^\UF72D"

-g modifies ~/Library/Preferences/.GlobalPreferences.plist. You need to reopen apps to apply changes, and the manually added shortcuts aren't displayed in Application Shortcuts.

share|improve this answer
Before I try it, how would I undo this? Is there something like -dict-remove? (Also, I'd love to know how you found this solution.) – foxcub Sep 13 '11 at 4:07
defaults delete -g NSUserKeyEquivalents. You can also edit the file manually with: f=~/Library/Preferences/.GlobalPreferences.plist; plutil -convert xml1 $f; open $f. I didn't find out about it from anywhere in particular. – user495470 Sep 13 '11 at 5:39
I think the key codes are wrong. It tries to set everything to be Ctrl+PageUp. Where can I lookup these codes? – foxcub Sep 13 '11 at 16:43
Sorry, fixed it. – user495470 Sep 14 '11 at 0:37
Accepting this answer, since it's a more direct approach to my question. (Sorry that I can't upvote it -- not enough reputation.) – foxcub Sep 14 '11 at 1:15

You could use iTerm, since that has a much more flexible shortcuts system, but you will inevitably come across another application that does not work the way you want.

I think you will find that Command+shift+[ and Command+shift+] are the only consistent shortcuts for switching between tabs and it is better to simply change your habits.

share|improve this answer
Is there a way to change Chrome shortcut for switching tabs to the same? (I think I know how to do it for MVim.) I'm Ok with changing my habits, but I need consistency. – foxcub Sep 10 '11 at 16:08
Chrome already uses those shortcuts, as does MacVim and every other application I have used, except for Adium. – Jared O'Connor Sep 11 '11 at 0:46
Ah, brilliant! I didn't realize this. Accepting your answer. – foxcub Sep 11 '11 at 15:36
Shift-Command-Left/Right Arrow also switch tabs in Terminal. Also, as of Mac OS X Lion 10.7, the "three-finger swipe" gesture switches tabs (as long as you don't have the system preference set to use three-finger swipe for something else). – Chris Page Sep 13 '11 at 20:16
Note that for people with (many) non-English keyboard layouts, any shortcuts involving keys like [ ] { } are hard to type. That's why I personally much prefer shortcuts that use keys that aren't dependent on keyboard layout. Like PageUp and PageDown. – tml Dec 27 '12 at 10:33

Lri's answer works (and FWIW, I upvoted it), but takes a bit of a shotgun approach: it creates global settings (instead of Terminal-specific settings), and some of the things it sets actually have no effect on Terminal at all -- I actually don't know what they're for.

If, like me, you're a bit paranoid and would prefer a more "surgical" approach, here's a modified version of Lri's answer:

defaults write NSUserKeyEquivalents -dict-add "Select Previous Tab"    "^\UF72C"
defaults write NSUserKeyEquivalents -dict-add "Select Next Tab"        "^\UF72D"

This adds only two keybindings, ^PageUp and ^PageDown, and adds them only to Terminal.

share|improve this answer
Thanks. That's good to know. – foxcub Mar 9 '12 at 22:09
Any idea if this should still work (in El Capitan) ? It's not working for me unfortunately. – Chris Apr 15 at 23:51
@Chris Looks like you are correct. This no longer seems to work! For one thing, the menus items have changed names (They are now say "Show" instead of "Select), but even correcting for that this setting doesn't seem to have any effect. I actually can't seem to get NSUserKeyEquivalents to work for Terminal at all in El Capitan. Ugh – Laurence Gonsalves Apr 16 at 2:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .