Skip to content

Instantly share code, notes, and snippets.

@tomsaleeba
Last active Feb 20, 2019
Embed
What would you like to do?
FISH shell VI keybindings with ctrl-<arrow> word navigation
  1. enable VI mode
    fish_vi_key_bindings
    
  2. restore the word navigation keys I'm used to in insert mode
    cat << EOF > ~/.config/fish/functions/fish_user_key_bindings.fish
    function fish_user_key_bindings
      bind -M insert \e\[1\;5C nextd-or-forward-word   # ctrl-right
      bind -M insert \e\[1\;5D prevd-or-backward-word  # ctrl-left
      bind -M insert \cK kill-line  # bring back emacs style <C-k> in insert mode
    end
    EOF
    

Thanks to https://superuser.com/a/1092277/384058 for how to get the keys to be bound on terminal startup.

Thanks to https://unix.stackexchange.com/a/76591/68885 for some useful tips on finding keycodes.

fish_key_reader is a useful tool to figure out a key sequence.

You can use

sed -n l

...to dump the escape codes when you press keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment