2

Let's say I want to bind R to redo in vicmd mode.

This works.

bindkey -a r redo

If I change it to this, it does not work.

bindkey -a rr redo

I have tried different things with no success. Is this not possible? I know it should be possible to bind sequences to keys in emacs mode, but can you do the same with letters in vi mode?

1

In the standard vicmd mode R is already bound to vi-replace-chars.

So when you define R+R to redo with

bindkey -a rr redo

you have two possible actions Zsh could follow when R is pressed

  1. interpret it as the command vi-replace-chars or
  2. wait for a second character and then interpret the command redo

The algorithm for matching keyboard commands in Zsh favors short commands so it will always use the 1. action.

To stop Zsh from doing this you first need to remove the binding for R with

bindkey -a -r r

and then add your new option with

bindkey -a rr redo

You can then also add vi-replace-chars with

bindkey -a re vi-replace-chars
1
  • Ah thank you for that information. Based on what I read, for emacs mode you could have both something like '^x' and '^x^a' and it would wait long enough. Unbinding r fixed the problem; I should have tried that right away. Thank you. – noctuid Mar 29 '14 at 15: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.