How to redo the insertion mode of the contribution to "jk" in the sink?

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

i.e. in vim:

inoremap jk <esc>

bash:

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

ZH

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

What is the shell equivalent?

+4
source share
2 answers

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

https://fedragon.imtqy.com/vimode-fishshell-osx/

TL; DR;)

~/.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
-3
source

I assume that you have already enabled vi mode by running fish_vi_key_bindings. Otherwise, the question does not make sense :-)

Create a file called ~ / .config / fish / functions / fish_user_key_bindings.fish that contains the following:

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

bind , , . , vi emacs, , vi:

if test "$__fish_active_key_bindings" = "fish_vi_key_bindings"
    bind ....
end
+1

Source: https://habr.com/ru/post/1694073/


All Articles