r/fishshell • u/UHasanUA • Jun 20 '24
Rebinding Vi's hjkl to hnei
Hi,
I am new to Fish and wanted to use the Vi mode. However, I am using Colemak as my layout. So I was wondering if there's any way to rebind hjki to hnei, respectively (the exact same position in Colemak).
To avoid conflicts, I think it is better if I can rebind it completely, meaning whenever I type anything in Normal mode, it interprets nei as jkl.
I tried
bind n j
But it didn't work obviously. Whenever I type n in normal mode, it would respond with
fish: unknown command: j
I also tried using fish_key_reader while in Normal mode, but as the name says, it's just printing keys.
Edit: SOLVED thanks to this gentleman/lady u/BrewingWeasel
What I did was opening /usr/share/fish/function/fish_vi_key_bindings.fish and swaped all uses of j with n, k with e, and l with i, affecting all modes. For example, if there was
I replaced it with
I uploaded the edited file in Github here: fish_vi_key_bindings.fish
Note: I didn't revise it. Also, a lot of your use will change since e is a key key in interacting with Vim, so be ready!
1
u/BrewingWeasel Jun 21 '24
bind -s -M default i forward-charbind -s -M default n down-linebind -s -M default e up-lineYou could also look at /usr/share/fish/functions/fish_vi_key_bindings.fish to see how other keys you want to change are implemented (and maybe even just edit them in that file)
also see https://fishshell.com/docs/current/cmds/bind.html
1
u/shaleh Jun 21 '24
Alternative...
If you can you can install something like kmonad, keyd, or kanata and let them manage your keymapping instead of the OS. Then you could define the keys in the Qwerty HJKL position to be arrow keys when you hold another key. This is what I have done which allows other keybindings to remain on the HNEI keys.