Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Troublesome Key Bindings



"Zvi Har'El" <rl@xxxxxxxxxxxxxxxxxxx> wrote:
> I am using zsh in vi insert mode (being an fanatic ViM user). After doing
> compinit, which introduced many new key binding, I started having troubles in
> history searches: Although most of the new bindings have the prefix ^X, there
> are three with a prefix ^[, i.e., the escape character. These are
> 
> 	"^[," _history-complete-newer
> 	"^[/" _history-complete-older
> 	"^[~" _bash_complete-word
> 
> The second of this trio is ***very troublesome***, to say the least!!! To
> search the history in vi mode, I have to hit the escape character - to switch
> to vi command mode, and then the slash character.

It's only the _bash* functions that depend on the particular binding ---
and that's only to make it easy to set things up like bash; they actually
do basic completion things which can be managed other ways (they weren't
intended to be anything more than a simple trick for compatibility).

So for the first two, you can simply use bindkey to map them to something
else straight away:
  bindkey '^X/' _history-complete-older
If you need any of the non-contextual bash-style completions, you can look
in the function _bash_completions and pick out the ones you want.  This
could be as simple as

_complete_users() {
  setopt localoptions ${_comp_options[@]}

  _main_complete _users
}
zle -C _complete_users .complete-word _complete_users
bindkey '<your-binding>' _complete_users

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070



Messages sorted by: Reverse Date, Date, Thread, Author