0

I want to remap some of the default movement bindings in fish's vi-mode (I'm using version 3.0). Specifically I want to change the $ and ^ key mappings to be E and B respectively to match what I use in vim - but I cannot find any documentation on how to do this anywhere. Does anybody know how/if it is possible to do this?

0

You should always specify which version of the program(s) you are using. Because in this case the preferred solution differs slightly between fish v2.x and v3.0. But in both cases it involves the bind command. So man bind is a good place to start.

Assuming you're using fish v2.x you'll want to create a function named fish_user_key_bindings in the file ~/.config/fish/functions/fish_user_key_bindings.fish. You'll place your desired bind commands in that function. You'll find the default bindings in /usr/local/share/fish/functions/fish_vi_key_bindings.fish (the directory might be different on your system). You'll want to add lines such as these to your fish_user_key_bindings.fish script:

function fish_user_key_bindings
    bind -m default \$ end-of-line
    bind -m default ^ beginning-of-line
end
  • Oh, sorry. I am using 3.0. Edited question. – Arthur Allshire Feb 8 at 19:33
  • My answer works with fish 3.0 as well although putting the bind commands in a fish_user_key_bindings function is no longer necessary. See github.com/fish-shell/fish-shell/issues/5191. – Kurtis Rader Feb 8 at 19:43
  • @kurtis, "no longer necessary", but if I have that function will I need to change it? – glenn jackman Feb 8 at 20:33
  • No need to change your use of fish_user_key_bindings.fish. The "no longer necessary" part of my answer simply alludes to the fact that in fish 3.0 you can define custom bindings without having to use that function. But that function is still supported. – Kurtis Rader Feb 9 at 18:14

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.