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

Re: zle: vi mode: wrong undo handling on fresh lines



On Sep 22, 10:27pm, Hauke Petersen wrote:
}
} > "zle -K viins" means you're still in whatever "mode" you were
} > in before (emacs, vicmd, or viins), but have started using the keymap
} > normally used for viins mode.
} > "zle vi-insert" causes an actual change of mode
} 
} If there's an underlying difference, man zshzle(1) should probably say
} the following differently:
} 
}                      zle-line-init() { zle -K vicmd; }

Hmm, it probably would in fact be better to use "zle vi-cmd-mode" in
that example, but the differences between emacs mode and vicmd mode
are less extreme than emacs and viins.

} > Until the bug is fixed, try something like
} >
} >   zle-line-init() { [[ -o vi ]] && { zle vi-cmd-mode; zle vi-insert } }
} 
} Curiously:
} 
}     % EDITOR=vi zsh -f
}     % bindkey -lL main
}     bindkey -A viins main
}     % [[ -o vi ]] && echo yes

Heh.  Hence "try something like" not "do exactly this" ... what you use
in place of [[ -o vi ]] depends on how you got into viins mode in the
first place.  A more universal test would be [[ $KEYMAP == viins ]],
and now that I think of it vi-cmd-mode may move the cursor back one
postion, so:

    zle-line-init() {
      [[ $KEYMAP == viins ]] && {
	zle vi-cmd-mode
	zle vi-add-next
      }
    }



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