Option-arrow navigation in iTerm2
Update: See the comments for more (and possibly better) solutions from readers!
I’ve been trying to get Option-arrow keys to move by word in iTerm2. I figured out a solution, but it’s weird. If anyone has an explanation or a better way to do this, let me know.
First, I had to edit my
~/.inputrc file and add these lines:
"\e[1;5C": forward-word "\e[1;5D": backward-word
Then I had to set up in iTerm2 preferences–under Profiles->Keys–the options for both key combinations:
- Add a hotkey with the plus symbol at the bottom of the hotkey list
- Set the keyboard shortcut by pressing Option-left or Option-right
- Set the action to “Send Escape Sequence”
- Set the Esc+ field to:
- [1;5C (Option-Right)
- [1;5D (Option-Left)
With these in place both work swimmingly. I don’t know why I had to do both parts, though…