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

Re: Starting replace-string minibuffer in Vi command-mode



On Mar 19, 12:39am, Nikolai Weibull wrote:
}
} I like having the replace-string function, but as I invoke it from Vi
} command-mode (through a binding to ":s") the minibuffer will also be
} in Vi command-mode when I'm expecting Vi insert-mode.

My first thought when I saw this was "if what you really want is vi,
why is replace-string good enough?"

E.g.,

    autoload -U edit-command-line
    ex-mode() { VISUAL=ex edit-command-line }
    zle -N ex-mode
    bindkey -M vicmd : ex-mode

Unfortunately I find that vim is seriously brain-damaged in ex mode.
It switches to the alternate screen in an xterm (which seems silly),
and even if given TERM=dumb it comes up in no-echo mode so you can't
see what you're typing (which must have something to do with calling
it from inside zle, but I haven't yet figured out what).

} Is there even a way to do it with the current implementation of
} read-from-minibuffer/"zle recursive-edit"?

In the absence of Peter's patch, I think this will do it:

    autoload -U replace-string
    vi-replace-string() {
      zle -K viins
      replace-string
    }
    zle -N vi-replace-string
    bindkey -M vicmd :s vi-replace-string



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