Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I was reading up in the Linux manual and I noticed that it said I could use control+left and control+right to move forward and back words in the terminal while editing.

"Pressing Ctrl plus the Left or Right arrow key moves backward or forward a word at a time, as does pressing Esc and then B or F."

On OS X control+left and control+right normally control spaces. I have disabled those. I also tried to use the preferences pane to set the keyboard shortcuts:

enter image description here

enter image description here

However this does not work and causes this error:

enter image description here

Also, if I am in iTerm and use alt+escape then B or F the character moves back and forth. This was happening before any of my config changes. But I'd really like to be able to use control + the arrow keys.

share|improve this question
Incidentally, a more parsimonious way to achieve this might simply be to map command+left and command+right instead of ctrl+left and ctrl+right. I didn't need to disable anything system-wide to accomplish this. –  mohawkjohn Jul 16 '14 at 19:35

2 Answers 2

up vote 50 down vote accepted


Just add the following to ~/.inputrc:

"\e[1;5D": backward-word
"\e[1;5C": forward-word

See here for some more explanation. If you want to use the alt key instead for word-to-word movement (like default OS X behavior), use:

"\e[1;9D": backward-word
"\e[1;9C": forward-word


zsh by default does not use the readline library and therefore won't read ~/.inputrc. To get the same functionality, you could add the following to your ~/.zshrc – this again would use the alt key:

bindkey -e
bindkey '^[[1;9C' forward-word
bindkey '^[[1;9D' backward-word

See this documentation for more about the built-in zsh line editor (zle).

Why is this? You've set up your profile to use the Xterm defaults:

enter image description here

This is why you'll need to "catch" this sequence and tell readline what to do.

If the above still doesn't work and you are using OS X 10.9 (Mavericks) or there abouts, you probably need to disable the global Mission Control shortcuts which prevent Control+arrow keys from reaching iTerm, even if Mission Control itself is disabled. You can do so from System Preferences → Keyboard → Shortcuts → Mission Control:

mission control keyboard prefs

share|improve this answer
I try to follow the instruction to get the alt + left and alt + right keys working. I added the two lines to my .inputrc file, but the only thing what happens when I press the keys is that either a "D" or a "C" gets printed to the shell. I'm using iTerm2 with zsh shell. Any ideas? –  Flo Nov 27 '12 at 11:23
@Flo Try adding the lines bindkey -e, bindkey '^[[1;9C' forward-word and bindkey '^[[1;9D' backward-word to your ~/.zshrc instead. IIRC zsh won't read .inputrc – or at least it works for me this way. –  slhck Nov 27 '12 at 11:49
@slhck, sure I will create a new question, though alt+left does work on vim, alt+right doesn't. Very weird, I will create a new question now. –  Ben Mezger Sep 2 '13 at 16:15
Not working for me with ctrl-left/right + bash, but works fine if I set it up for alt-left/right. –  Dalin Jan 18 '14 at 3:22
For OSX + zsh + iTerm2 + ctrl-left/right use the following: bindkey -e; bindkey '\e\e[C' forward-word; bindkey '\e\e[D' backward-word –  Artur Bodera Apr 11 '14 at 9:30

I used a different approach. Using BetterTouchTool I programmed a custom keyboard shortcut for iTerm2. When I press alt-left in iTerm2, it sends the keyboard shortcut ctrl-left with the action "Send keyboard shortcut to specific application". The application is iTerm2. I did the same for alt-right mapped to ctrl-right.

The effect is that pressing alt-left or alt-right in iTerm sends a ctrl-left or ctrl-right directly to iTerm2, bypassing the usual system-wide shortcut to move a desktop left or right. Like this I get the typical mac behaviour in iTerm2, on local terminal sessions, but also on remote SSH sessions and I can use the standard ctrl-left / ctrl-right to move to different desktops. I wrote it up here:


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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