I got asked how to use the vi mode alongside with some remapped keys in fish yesterday, and since I felt like it is a useful and good thing to know, I decided to write it down here.

The command for activating the vi keybindings is fish_vi_key_bindings, to make these permanent, it has to be added to the ~/.config/fish/config.fish config file.

I remap my escape key to <jk>, to reduce the finger movement on the keyboard, since commonly, in the touch typing system, your right hand rests on <hjkl>. In fish the remapping can be done by creating a ~/.config/fish/functions/fish_user_key_bindings.fish function:

function fish_user_key_bindings bind -M insert jk "if commandline -P; commandline -f cancel; else; set fish_bind_mode default; commandline -f backward-char force-repaint; end" end

Happy hacking!


Stack Overflow: How to remap escape insert mode to ‘jk’ in fish shell?