Skip to main content

Vi-mode in fish shell on OSX

·1 min

Vi-mode for fish is merged into the master branch but still not released (will be released in 2.2.0), so you need to install it from HEAD:

brew install fish --HEAD

Now edit .config/fish/config.fish and add

set fish_key_bindings fish_vi_key_bindings

Done, you are good to go. When you want to go back to Normal mode, hit Escape or Ctrl-C.

Additional options #

Open new shells in Insert mode #

If you want to be in insert mode when opening a new shell, also add

set fish_bind_mode insert

Define custom keybindings #

Let’s say that you want to be able to go back to Normal mode by hitting jk (I love that keybinding, by the way). In order to do that (or to define any custom keybinding), you can do the following:

vim .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

Now go back to your config.fish and replace

set fish_key_bindings fish_vi_key_bindings

with

set fish_key_bindings fish_user_key_bindings

That’s it. Enjoy your vi-mode!