How to remap Caps Lock to Control on Linux
2022-01-15
One of the first things I do on a new computer is remap Caps Lock to Control.
I use C-[ instead of Esc in Vim, so I use Control
a lot. I can't say the same for Caps Lock.
To permanently map Caps Lock to Control on Linux,
add the following line to /etc/default/keyboard:
XKBOPTIONS="ctrl:swapcaps"
It will be applied after reboot for all users on that machine.
If you just want to make the change until the next reboot, do
setxkbmap -layout us -option ctrl:nocaps. To make it permanent
just for yourself, add that to your ~/.bashrc.
More info here.