zsh-vi-mode icon indicating copy to clipboard operation
zsh-vi-mode copied to clipboard

How to map ctrl-c to go to quit insert mode

Open rzksobhy78 opened this issue 3 years ago • 4 comments

how can I use ctrl+c to quit insert mode and go to normal mode

rzksobhy78 avatar Dec 07 '21 22:12 rzksobhy78

Hi @rzksobhy78

For custom escape vi mode, please see this section.

Thanks and Regards

jeffreytse avatar Dec 08 '21 05:12 jeffreytse

that doesn't work I tried ZVM_VI_INSERT_ESCAPE_BINDKEY=^c bindkey -M viins '^c' vi-cmd-mode

rzksobhy78 avatar Dec 08 '21 15:12 rzksobhy78

Hello, I still have the problem, is there any solution?

javierMorales9 avatar Aug 21 '22 12:08 javierMorales9

For anyone having this issue, you can leverage hooks to set ctrl-c as the escape key only when editing and still be able to send SIGINTs when a command is running. Here's an example:

precmd() {
  # Set SIGINT to ctrl-e while editing a command
  stty intr \^E
}
preexec() {
  # Now set it to ctrl-c when a command is running
  stty intr \^C
}
ZVM_VI_INSERT_ESCAPE_BINDKEY=^C

bonofiglio avatar Dec 10 '23 00:12 bonofiglio