How to cancel a completion in zsh prezto in vi insert mode?

250 views Asked by At

In zsh, with emacs key mapping mode, Control + _ will cancel a completion.

Example:

echo $EDITOR[tab]

will be completed as:

echo vim

Pressing Control + _ will restore the editor to:

echo $EDITOR

I want to do the same thing with vi key mapping mode. Is there a way to do it? Is there already a key mapping to do it? Control + _ does not work neither in insert mode nor in normal mode.

The u (undo) will remove the entire line.

1

There are 1 answers

0
matt On

I finally found how to do it.

bindkey -l will print a list of existing keymap names.
bindkey -M <keymap> will list all bindings for a given keymap.

So I compared emacs and viins bindings and added the following line:

bindkey -M viins "$key_info[Control]_" undo

to the .zprezto/modules/editor/init.zsh. And it works.

I made a pull request to add this mapping to prezto: https://github.com/sorin-ionescu/prezto/pull/1860