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

Re: Why can't the 'main' keymap be an alias from 'vicmd'

On Dec 9, 10:00am, Peter Stephenson wrote:
} Subject: Re: Why can't the 'main' keymap be an alias from 'vicmd'
} On Thu, 9 Dec 2010 09:15:41 +1030
} first name <33facebook@xxxxxxxxx> wrote:
} > I mean, why is it possible to have 'main' linked to viins and have
} > <esc> bound to the 'vi-cmd' widget, and not have the main linked to
} > vicmd while `i' and `a' bound to the 'vi-insert' widget?
} <esc> doesn't map to vi-cmd, it means 'leave insert mode and return to
} the main keymap'.

I think you have that backwards, Peter:

schaefer<505> (bindkey -v; bindkey -lL)
bindkey -N command
bindkey -N emacs
bindkey -N isearch
bindkey -N listscroll
bindkey -A viins main
bindkey -N menuselect
bindkey -N vicmd
bindkey -N viins

What you really mean is that vi-insert and all its friends don't mean
"select the viins keymap", they mean "position the cursor as needed
and switch back to the main keymap".

Doc says:

vi-cmd-mode (^X^V) (unbound) (^[)
     Enter command mode; that is, select the `vicmd' keymap.  Yes, this
     is bound by default in emacs mode.

This is the real hidden reason that "bindkey -A vicmd main" doesn't
work; it's because vicmd is not the alternate to viins, it's the
alternate to *anything else you might want to use as main*.

It didn't even used to have a name.  Originally it was just "the
alternate keymap" and the only way you could put things into it was
with "bindkey -a" for "alternate".  It happens that the default set
of bindings for the alternate keymap are those corresponding to the
vi command mode, is all.

If we had thought about it hard enough, when we introduced the magic
name "main" for the primary keymap we should also have introduced a
magic name "alt" for the bindkey -a keymap, and let you have any two
keymaps as main/alt.  Then bindkey -v would select viins/vicmd, and
bindkey -e would select emacs/vicmd, and we could have documented
that vi-cmd-mode really means alt-keymap-mode.

Maybe it's not too late to do this anyway, as it won't change any of
the old behavior.

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