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?


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.

  • 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
  • 1
    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. – Lri 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. lri.me/chars – Lri 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.

  • 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
  • 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 com.apple.Terminal NSUserKeyEquivalents -dict-add "Select Previous Tab"    "^\UF72C"
defaults write com.apple.Terminal NSUserKeyEquivalents -dict-add "Select Next Tab"        "^\UF72D"

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

  • Any idea if this should still work (in El Capitan) ? It's not working for me unfortunately. – Chris Apr 15 '16 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 '16 at 2:47

Based on this answer here's a version of this for macOS High Sierra:

defaults write com.apple.Terminal NSUserKeyEquivalents -dict-add "Show Next Tab" "^\UF72D"
defaults write com.apple.Terminal NSUserKeyEquivalents -dict-add "Show Previous Tab" "^\UF72C"
  • Confirmed that this works on Mojave, though this answer seems to be a duplicate of Laurence Gonsalves' answer. Also, PSA: remember to restart Terminal after running. – RACKGNOME Jan 6 '20 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.