1

I'm trying to also have access to my arrow keys from the default Vim hjkl.

Since CtrlShiftAlt seems to be a rare key combo, I was thinking about using that.

How would I do that using setxkbmap (or another equivalent tool)?

1 Answer 1

2

using a similar setup with caps+hjkl via xkb. i'm sure you can adapt it easily. caps is set as level5 modifier.

1. put xkb_symbols "vim" in ~/.config/xkb/symbols/vim-keys

default partial alphanumeric_keys modifier_keys xkb_symbols "vim" { name[Group1]= "L5: vim arrow keys"; key <AC06> { type = "EIGHT_LEVEL", symbols[Group1] = [ h, H, ugrave, Ugrave, Left, Left, Left, Left ] }; key <AC07> { type = "EIGHT_LEVEL", symbols[Group1] = [ j, J, uacute, Uacute, Down, Down, Down, Down ] }; key <AC08> { type = "EIGHT_LEVEL", symbols[Group1] = [ k, K, U0133, U0132, Up, Up, Up, Up ] }; key <AC09> { type = "EIGHT_LEVEL", symbols[Group1] = [ l, L, oslash, Oslash, Right, Right, Right, Right ] }; include "level5(caps_switch)" }; 

2. add level5 group rules/evdev.xml

copy /usr/share/X11/xkb/rules/evdev.xml to ~/.config/xkb/rules/evdev.xml and add

 <group allowMultipleSelection="true"> <configItem> <name>L5</name> <description>Level5 keys</description> </configItem> <option> <configItem> <name>l5:vim</name> <description>vim: hjkl arrows</description> </configItem> </option> </group> 

3. map rules to symbols in rules/evdev

copy /usr/share/X11/xkb/rules/evdev to ~/.config/xkb/rules/evdev and add

l5:vim = +l5(vim)` 

4. activate

e.g. in gnome-settings or via

$ setxkbmap us -option l5:vim 

now you can press caps+hjkl for arrow keys, works nicely on my laptops without a proper qmk keyboard.

note: quickly copy pasted this from my own setup, renamed a bit, hope i didnt miss anything and it helps you!

2
  • I, as well as many Vim users, use CapsLock as Esc actually. Won't this conflict with it? This looks way more complicated than I expected too. Commented Jun 13, 2023 at 15:10
  • yes, this will conflict with caps:escape. for me it's a workaround for not having qmk on laptops and that's ok. on qmk i have caps to be esc on tap, mod on hold, love that. you could use e.g. right-alt as level3 mod and add the keys there, which would be the 3rd/4th columns. Commented Jun 15, 2023 at 7:17

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.