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

vi-mode: editor function

Dear all,

I have written a theme for the oh-my-zsh prompt from robbyrussel because I was 
sometimes confused about the different vi modes. My prompt shows, at a glance,
which vi mode is active, similar to the vim airline plugin.

For the indicators, the theme uses functions like the following:
    vi-insert() {
      builtin zle .vi-insert
    zle -N vi-insert
    bindkey -M vicmd "i" vi-insert

    vi-replace() {
      builtin zle .vi-replace
    zle -N vi-replace
    bindkey -M vicmd "R" vi-replace

The MODE variable finally sets the indicator for the prompt.
This works very well, except in the following case. When I call the editor with
    [ESC] [v] 
I can edit the command line with vi, as expected. But after closing the editor,
the zsh prompt is in INSERT mode. It has been in NORMAL mode before. And this is
not considered in my script. Thus, I would like to know, whether there is a
function, equivalent to the ones above. I am looking for something like this:
    vi-editor() {
      MODE="INSERT"                    # prompt is in INSERT mode after editing
      builtin zle .vi-editor
    zle -N vi-editor
    bindkey -M vicmd "v" vi-editor

Unfortunately I could not find something like vi-editor it in the zshzle manual.
Has anybody an idea what I can use instead? Or what is the default vicmd for [v]?

Best regards

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