My .zshrc looks like this:

export EDITOR="/usr/bin/vim"

Now when I open a terminal and enter a keyboard shortcut like ctrla to go to the beginning of the line, it doesn't work. Instead, the string ^A (or some other string, depending on the shortcut I entered) gets entered to the terminal:

emlai:~ % ^A

Removing the word export from my .zshrc makes the keyboard shortcuts work properly:


Exporting EDITOR as something else than vim makes the keyboard shortcuts work too, e.g.:

export EDITOR="/usr/bin/nano"

Why does this happen?

I tested this with bash as well, and the keyboard shortcuts work properly in all cases there.

1 Answer 1


zsh like most modern shells have a choice between two different keyboard mappings for command-line editing: a vi one and an emacs one. In some shells (like tcsh or readline-based ones like bash), the emacs one is the default and probably the one you expect.

With zsh, you get emacs mode by default unless $EDITOR or $VISUAL contains vi (if you're a vi/nvi/vim/elvis user (though also vimacs and if $EDITOR is /home/victor/bin/emacs...), zsh assumes you prefer the vi mode).

To force a particular mode regardless of the value of $EDITOR, add:

bindkey -e # for emacs
bindkey -v # for vi

or their more portable equivalent:

set -o emacs
set -o vi

to your ~/.zshrc. See

info -f zsh -n Keymaps

for details.

  • Interesting. Is there any reason to use bindkey over set -o?
    – zenith
    Apr 22, 2015 at 11:15
  • @zenith, probably not. bindkey is the tcsh way and original way. Nowadays they should be equivalent. Apr 22, 2015 at 11:29

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.