Bind Ctrl-C in fish vi-mode to switch from insert mode to normal mode

1.1k Views Asked by At

I would like to use Ctrl-C to go from insert to normal mode in fish vi-mode, as I do in vim. I'm fairly new to fish and couldn't get it to work, though I tried this in my config.fish:

bind -M insert \cc set fish_bind_mode 'default'

Strangely I am able to go from Visual to Normal mode with Ctrl-C. Thanks

1

There are 1 best solutions below

4
On

Binding [ctrl-C] would require that you also change the stty intr character. Something that is currently impossible from within fish due to how it handles tty modes. You could, however, change it before starting fish. That would then free the character to be bound as you wish. Though you'll need to do this to get the correct behavior:

bind -M insert \cc 'set fish_bind_mode default; commandline -f repaint'