My Emacs keybindings in zsh are not working (CtrlA, CtrlE). I use zsh on OS X.

They might be bound to some other thing. I'm currently using oh-my-zsh.

And my .zshrc is over here.

enter image description here

  • @rene Done! thx for the advice! :D Commented Dec 24, 2012 at 16:52
  • From the screenshot I gather you are on Mac OS X? I have the same problem there in terminal. Ctrl+A/E/K are already taken in that OS (for use in text fields in the GUI), which might explain this.
    – Henno
    Commented Dec 25, 2012 at 5:35
  • @Henno really? Im using zsh atm, and when i use bash, the ctrl+a(go to the first char of line) and ctrl+e(go to the end of the line) works fine. but when i use zsh, it goes like the screenshot. so i think its an problem about zsh, not the OS :( Commented Dec 25, 2012 at 9:42
  • @TakehiroAdachi your fixed worked for me too!
    – Henno
    Commented Dec 26, 2012 at 18:13
  • @Henno Great :D! Commented Dec 27, 2012 at 6:40

2 Answers 2


I got the problem solved. Looks like oh-my-zsh was overriding the default keybindings.

When I added the below line at the end of my .zshrc, CtrlE and CtrlA worked:

bindkey -e
  • great, worked for me too!
    – Henno
    Commented Dec 26, 2012 at 18:13
  • fixed my problem too. FWIW, I also found the guilty party in my ~/.zshrc: # Lines configured by zsh-newuser-install HISTFILE=~/.histfile HISTSIZE=1000 SAVEHIST=1000 bindkey -v 👈 So it looks like it's Apple being "helpful".
    – JL Peyret
    Commented Jun 18, 2022 at 2:47
  • If one of the VISUAL or EDITOR environment variables contain the string 'vi' when the shell starts up then it will be 'viins', otherwise it will be 'emacs'.
    – Polluks
    Commented Jun 26, 2023 at 10:52

Generally speaking, you can find the code of a key by typing CtrlV and the key. You can then use this key with bindkey to map it to a zsh keyboard functionality (e.g. beginning-of-line).

In your specific case that would be CtrlV CtrlA and CtrlV CtrlE.

Then you can put the code in your .inputrc, the system /etc/inputrc, or your .zshrc like this:

bindkey '^A' beginning-of-line
bindkey '^E' end-of-line

This works for other keys too. For instance, I had some trouble with Home and End.

You should be able to use this trick in any terminal session : tty,

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .