Vim hjkl With Microsoft Powertoys
When I got my first mechanical keyboard one of the first thing I did was create
a layer where h
,j
,k
, and l
, Vim’s navigation keys, sent their
respective arrow key codes instead. This quickly became one of my favourite key
bindings that I would use everywhere. I’ve continued to code this setup into
any keyboard I can set it up on.
With mechanical keyboards this is easy since most come with great programmable tools out of the box. With the keyboard on my laptop though, and on my work laptop specifically, I’m a bit more limited as to what tools I can use. Installing something like AutoHotkey felt heavy-handed for something so simple. I also didn’t have any ambition to use AutoHotkey for anything else.
Thankfully I can use Microsoft
PowerToys on my work laptop without
issue. With a little work I was able to figure out a key combination that would
allow me to hold the Caps Lock key and use hjkl
as arrow keys, which is the
setup I usually go with on my mechanical keyboards.
In PowerToys Keyboard Manager I have the following setup in each section of the window.
Keys Section
Caps Lock
is mapped to Ctrl (Right)
I chose Ctrl (Right)
because I use Ctrl
+ L
in my web browser a lot to
target the address/search bar. I usually use the left Ctrl
button so I was
okay with giving up the right Ctrl
button.
Shortcuts Section
Ctrl (left)
+H
mapped toLeft
Ctrl (left)
+J
mapped toDown
Ctrl (left)
+K
mapped toUp
Ctrl (left)
+L
mapped toRight
Now I can hold Caps Lock
and use hjkl
as arrow keys without taking my hands
away from the home row.