MacOS – How to move through words when typing a command in iTerm2

configurationitermmacos

I'm in Lion

with iTerm2, Zsh and Oh-My-Zsh

but I cannot move through words when pressing: ALT+left arrow or CMD+left arrow or something

instead, when I press "ALT+right arrow" it prints [C
and when I press "SHIFT+ALT+left arrow" it prints D0

how I can config iTerm2 to behave like any other program when moving through words?

Best Answer

I finally found the solution to this problem here: https://coderwall.com/p/h6yfda. The necessary steps are shown below:

  1. Go to Preferences, Profile, Keys.
  2. Set your left ⌥ key to act as an escape character.
  3. Locate the current shortcut for ⌥ ← or create a new one, with the following settings:
    • Keyboard Shortcut: ⌥←
    • Action: Send Escape Sequence
    • Esc+: b
  4. repeat for the ⌥→ keyboard shortcut with the following settings:
    • Keyboard Shortcut: ⌥→
    • Action: Send Escape Sequence
    • Esc+: f