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:
EDITOR="/usr/bin/vim"
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.
Best Answer
zsh
like most modern shells have a choice between two different keyboard mappings for command-line editing: avi
one and anemacs
one. In some shells (liketcsh
orreadline
-based ones likebash
), theemacs
one is the default and probably the one you expect.With
zsh
, you getemacs
mode by default unless$EDITOR
or$VISUAL
containsvi
(if you're avi
/nvi
/vim
/elvis
user (though alsovimacs
and if$EDITOR
is/home/victor/bin/emacs
...),zsh
assumes you prefer thevi
mode).To force a particular mode regardless of the value of
$EDITOR
, add:or their more portable equivalent:
to your
~/.zshrc
. Seefor details.