jeffreytse / zsh-vi-mode

💻 A better and friendly vi(vim) mode plugin for ZSH.
MIT License
3.13k stars 109 forks source link

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

Open rzksobhy78 opened 2 years ago

rzksobhy78 commented 2 years ago

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

jeffreytse commented 2 years ago

Hi @rzksobhy78

For custom escape vi mode, please see this section.

Thanks and Regards

rzksobhy78 commented 2 years ago

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

javierMorales9 commented 2 years ago

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

bonofiglio commented 10 months ago

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