When you use option + arrow keys in your macOS teminal(such as ⌥ + ←
⌥ + →
), you can’t move cursor.
$ [D [C # option + arrow key doesn't work!
fix with zsh bindkey
To fix this, put this in your ~/.zshrc
.
bindkey "[D" backward-word
bindkey "[C" forward-word
See also
fix with iTerm2 Key mapping
Just open iTerm2, Profiles -> Edit Profiles -> Keys. Then you click on Presets and select: Natural Text Editing.
How to easy fix iTerm2 text navigation (cmd+arrow) · Raul Melo