2

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?

1 Answer 1

3

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
4
  • Oh, sorry. I am using 3.0. Edited question. Commented Feb 8, 2019 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. Commented Feb 8, 2019 at 19:43
  • @kurtis, "no longer necessary", but if I have that function will I need to change it? Commented Feb 8, 2019 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. Commented Feb 9, 2019 at 18:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .