默认情况下,Zsh vi 模式没有设置 ctrl-o 行为,我如何像 vim 一样工作?
答案1
就这么简单:
vi-cmd () {
local REPLY
# Read the next keystroke, look it up in the `vicmd` keymap and, if successful,
# evalute the widget bound to it in the context of the `vicmd` keymap.
zle .read-command -K vicmd &&
zle $REPLY -K vicmd
}
# Make a keyboard widget that calls the function above.
zle -N vi-cmd
# Bind the widget to Ctrl-O in the `viins` keymap.
bindkey -v '^O' vi-cmd