Take the 2-minute tour ×

For some reason I am unable to bind Ctrl-Left Arrow and Ctrl-Right Arrow to move between words in ZSH after installing oh-my-zsh on my MacBook Pro.

In iTerm2 I have my keybindings configured to "Send Escape Sequence" [1;5D and [1;5C, which worked before installing oh-my-zsh.

I also tried uncommenting

bindkey '^[^[[C' emacs-forward-word
bindkey '^[^[[D' emacs-backward-word

in ~/.oh-my-zsh/lib/key-bindings.zsh, also to no avail. In both scenarios, hitting Ctrl-Left/Right just sends "5D" and "5C" to the screen.

TLDR: Has anyone gotten Ctrl-Left and Ctrl-Right to move between words when using oh-my-zsh?

share|improve this question

migrated from serverfault.com Jun 23 '11 at 10:28

This question came from our site for system and network administrators.

4 Answers 4

Change your bindkey lines to:

bindkey '^[[1;5C' emacs-forward-word
bindkey '^[[1;5D' emacs-backward-word
share|improve this answer

This one worked for me:

bindkey "[C" emacs-forward-word   #control left
bindkey "[D" backward-word        #control right

In fact, I pressed Control+left and Control+right between the "" and that did the magic.

share|improve this answer

Press ^v(Ctrl-v) in the zsh shell, followed by the key-combination(Ctrl+left) which you wanna use, to get the corresponding bindkey value. Use this output in the command. It varies from system to system depending on the terminal driver, etc.

Peter Stephenson says ...the function keys on your keyboard... It depends a good deal on how your windowing system or terminal driver handles them... Hence it is better to validate all those key binds before running any such script, though it might not vary in most of the cases.

In my case Ctrl-left was ^[O5D. Hence, bindkey '^[O5D' backward-word

For detailed understanding of key bindings for zsh, check this guide. http://zsh.sourceforge.net/Guide/zshguide04.html

share|improve this answer

So you have your terminal emulator sending one CSI sequence (ESC+[+1;5C) for the key, but you've told your shell with the bindkey command to watch the terminal input for a different CSI sequence (ESC+ESC+[+C), and you are wondering why this doesn't work?

It doesn't work for the very obvious reason.

share|improve this answer

Your Answer


