109

I saw vi-mode implementation for fish shell, but I have no clue how to use it. Is there any tutorial available online describing basic functionality, e.g. how to switch modes?

NotTheDr01ds
  • 15,620
  • 5
  • 44
  • 70
sandric
  • 2,310
  • 3
  • 21
  • 26

2 Answers2

185

In fish 2.3.0 and later:

  • Run fish_vi_key_bindings to start vi mode
  • Run fish_default_key_bindings to go back to default mode

If you want to make it the default, add the fish_vi_key_bindings command to ~/.config/fish/config.fish.

hoijui
  • 3,615
  • 2
  • 33
  • 41
ridiculous_fish
  • 17,273
  • 1
  • 54
  • 61
  • 1
    See [this issue](https://github.com/fish-shell/fish-shell/issues/2254) for how to setup a different vi esc key. Fish versions after 2.2.0 should let you do this via a `fish_user_key_bindings` function, but in the meantime I used the solution shown by the first post on that issue in my `config.fish`. – Jay Apr 06 '16 at 15:38
  • 1
    To remove the annoying vi mode indicator (capital i for insert mode), override the fish_mode_prompt function. `alias -s fish_mode_prompt 'echo'` – Despertar Jun 26 '22 at 20:44
11

I am using fish 2.2.0. The following worked for me:

Edit $HOME/.config/fish/functions/fish_user_key_bindings.fish

function fish_user_key_bindings
  fish_vi_key_bindings
end

via this

amit kumar
  • 20,438
  • 23
  • 90
  • 126