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.

link|improve this question

feedback

1 Answer

up vote 1 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

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.

link|improve this answer
Thanks. What does the error "the global keyboard shortcut you have set is overridden by at least one profile" mean" ? Is that an iTerm profile conflict or a System Preferences -> Keyboard Shortcuts conflict? – cwd Nov 14 '11 at 19:48
1  
As you see in the screenshot, you have a default iTerm profile which overrides your settings under Keys. This is what the message says. Didn't it work for you? – slhck Nov 14 '11 at 19:56
perfect - worked like a charm. didn't realize that was on a different tab. – cwd Nov 14 '11 at 20:18
feedback

Your Answer

 
or
required, but never shown

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