From: Julien Jehannet <julien@smaf.org>
To: Sepp Tannhuber <sepp.tannhuber@yahoo.de>
Cc: "zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: Re: vi-mode: editor function [solved]
Date: Thu, 15 May 2014 13:18:29 +0200 [thread overview]
Message-ID: <CADweS+YiAOZMeP_TrYDnOYZ3o0SQL0kr97eZas02OpV3KjVaAQ@mail.gmail.com> (raw)
In-Reply-To: <1400147444.59377.YahooMailNeo@web172703.mail.ir2.yahoo.com>
[-- Attachment #1.1: Type: text/plain, Size: 1972 bytes --]
FWIW, you could simplify your builtin redefinitions by using the ZLE_STATE
variable.
Changes from 4.3.11:
The parameter ZLE_STATE, available in user-defined line editor widgets,
gives information on the state of the line editor. Currently this is
whether the line editor is in insert or overwrite mode.
2014-05-15 11:50 GMT+02:00 Sepp Tannhuber <sepp.tannhuber@yahoo.de>:
> Dear Bart,
>
> thank you for the hint. Indeed, I found an edit-command-line module in
> zshcontrib.
> And yes, it is loaded by oh-my-zsh. So I could fix my theme script.
>
> Unfortunately, I have no idea how to set the MODE variable the way you
> mentioned.
> If anybody wants to tell me, you can find the script at
>
> https://github.com/tannhuber/oh-my-zsh/blob/master/themes/budspencer.zsh-theme
> But don't waste your time. Everything is working well, now.
>
> Thank you
> Joseph
> Bart Schaefer <schaefer@brasslantern.com> schrieb am 3:50 Donnerstag,
> 15.Mai 2014:
>
> On May 14, 9:18pm, Sepp Tannhuber wrote:
> } Subject: vi-mode: editor function
>
> }
> } 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.
> [...]
> } 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]?
>
> There is no default binding for v in vicmd mode, so you are encountering
> something installed for you by oh-my-zsh. Most likely it is the user-
> contributed edit-command-line widget (man zshcontrib).
>
> If oh-my-zsh hasn't already pre-empted the zle-line-init, zle-line-finish,
> and zle-keymap-select widgets, you might find it more effective to set the
> MODE variable with those, rather than trying to override all the individual
> widgets that might change mode.
--
J u l i e n J e h a n n e t
[-- Attachment #1.2: Type: text/html, Size: 2660 bytes --]
[-- Attachment #2: budspencer.zsh-theme.patch --]
[-- Type: text/x-diff, Size: 2552 bytes --]
--- budspencer.zsh-theme.orig 2014-05-15 12:47:04.000000000 +0200
+++ budspencer.zsh-theme 2014-05-15 13:16:35.000000000 +0200
@@ -162,76 +162,6 @@
}
# Vi modes
-vi-add-eol() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-add-eol
-}
-zle -N vi-add-eol
-bindkey -M vicmd "A" vi-add-eol
-
-vi-add-next() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-add-next
-}
-zle -N vi-add-next
-bindkey -M vicmd "a" vi-add-next
-
-vi-change() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-change
-}
-zle -N vi-change
-bindkey -M vicmd "c" vi-change
-
-vi-change-eol() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-change-eol
-}
-zle -N vi-change-eol
-bindkey -M vicmd "C" vi-change-eol
-
-vi-change-whole-line() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-change-whole-line
-}
-zle -N vi-change-whole-line
-bindkey -M vicmd "S" vi-change-whole-line
-
-vi-insert() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-insert
-}
-zle -N vi-insert
-bindkey -M vicmd "i" vi-insert
-
-vi-insert-bol() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-insert-bol
-}
-zle -N vi-insert-bol
-bindkey -M vicmd "I" vi-insert-bol
-
-vi-open-line-above() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-open-line-above
-}
-zle -N vi-open-line-above
-bindkey -M vicmd "O" vi-open-line-above
-
-vi-open-line-below() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-open-line-below
-}
-zle -N vi-open-line-below
-bindkey -M vicmd "o" vi-open-line-below
-
-vi-substitute() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-substitute
-}
-zle -N vi-substitute
-bindkey -M vicmd "s" vi-substitute
-
vi-cmd-mode() {
ZSH_VI_MODE="NORMAL"
builtin zle .vi-cmd-mode
@@ -247,7 +177,6 @@
bindkey -M vicmd "R" vi-replace
vi-edit-command-line() {
- ZSH_VI_MODE="INSERT"
vim_mode=$vim_ins_mode
dir_mode=$dir_ins_mode
fgcolor=136
@@ -264,27 +193,25 @@
vim_cmd_mode="%{%K{33}%}%{%F{0}%}"
vim_rpl_mode="%{%K{160}%}%{%F{0}%}"
vim_mode=$vim_ins_mode
-fgcolor=136
-ZSH_VI_MODE="INSERT"
function zle-keymap-select {
-if [ "$ZSH_VI_MODE" = "INSERT" ]
+if [ "$ZSH_VI_MODE" = "NORMAL" ]
+then
+ vim_mode=$vim_cmd_mode
+ dir_mode=$dir_cmd_mode
+ fgcolor=33
+elif [[ "$ZLE_STATE" = *insert* ]]
then
fgcolor=136
vim_mode=$vim_ins_mode
dir_mode=$dir_ins_mode
-fi
-if [ "$ZSH_VI_MODE" = "REPLACE" ]
+ ZSH_VI_MODE="INSERT"
+elif [[ "$ZLE_STATE" = *overwrite* ]]
then
vim_mode=$vim_rpl_mode
dir_mode=$dir_rpl_mode
fgcolor=160
-fi
-if [ "$ZSH_VI_MODE" = "NORMAL" ]
-then
- vim_mode=$vim_cmd_mode
- dir_mode=$dir_cmd_mode
- fgcolor=33
+ ZSH_VI_MODE="REPLACE"
fi
zle reset-prompt
}
next prev parent reply other threads:[~2014-05-15 11:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-14 20:18 vi-mode: editor function Sepp Tannhuber
2014-05-15 1:48 ` Bart Schaefer
2014-05-15 9:50 ` vi-mode: editor function [solved] Sepp Tannhuber
2014-05-15 11:18 ` Julien Jehannet [this message]
2014-05-15 14:32 ` Sepp Tannhuber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADweS+YiAOZMeP_TrYDnOYZ3o0SQL0kr97eZas02OpV3KjVaAQ@mail.gmail.com \
--to=julien@smaf.org \
--cc=sepp.tannhuber@yahoo.de \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).