Search code examples
shellvimvifish

How to remap escape insert mode to 'jk' in fish shell?


I use jk as my escape sequence in vim as well as vi-mode for bash and zshell. How do I do this in fish shell?

i.e. in vim:

inoremap jk <esc>

bash:

bind -m vi-insert '"jk": vi-movement-mode'

zsh

bindkey -M viins 'jk' vi-cmd-mode

What is the fish shell equivalent?


Solution

  • Here is a blog post that does exactly what I was looking for:

    https://fedragon.github.io/blog/2015/03/22/vimode-fishshell-osx/

    TLDR;)

    ~/.config/fish/functions/fish_user_key_bindings.fish
    ---------------------------------------------------
    function fish_user_key_bindings
      fish_vi_key_bindings
      bind -M insert -m default jk backward-char force-repaint
    end
    

    And

    ~/.config/fish/config.fish
    ---------------------------------------------------
    set fish_key_bindings fish_user_key_bindings