2

In emacs, M-f moves the caret to the end of the next word. In zsh, M-f (or rather alt-f) moves the caret to the beginning of the next word.

For a more consistent experience, I'd like to have zsh alt-f mirror emacs behavior.

How can I do this?

4
bindkey '\ef' emacs-forward-word

See:

zle -la | grep word

to list the widgets that contain the word word.

info --index-search=emacs-forward-word zsh

to get the documentation on a given widget.

  • Mapping \M-f to emacs-forward-word did not work for me. Searching with bindkey | grep forward-word showed that the correct mapping on my system was to ^[f and ^[F. – ehuang Dec 23 '13 at 19:55
  • 1
    @EricHuang, yes sorry, \M-f is f with the eighth bit set. Some terminals send that upon Alt-F but they are getting rare in those utf8 days. I'll amend the answer as \ef is likely to be useful to more people. – Stéphane Chazelas Dec 23 '13 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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