Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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
share|improve this answer
    
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. –  angelic_sedition Mar 29 at 15:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.