Moving a word forward in z shell
If you're using iTerm2 on OSX, you can use the Natural Text Editing preset under Preferences -> Profile -> Keys.
This supports these key combos (which are very similar to other editors):
- alt/option + left = move left one word
- alt/option + right = move right one word
The ZLE widget for moving forward by one word is forward-word
. Therefore, you may use bindkey
to bind this widget to any key you want.
For example,
$> bindkey ^O forward-word
would allow you to move forward by one word when pressing Ctrl-O
. Note that ^O
is actually a quoted insert of Control followed by O
.
Your zsh command prompt works either like emacs or like vi. If it works like vi, put it in command mode (esc
) and type w
. If it works like emacs, use M-f
.
More information available at man zshzle.