For vim users, rebinding
CAPS LOCK to the
ESCAPE key makes it easier to switch modes.
For Emacs users, it's helpful to rebind
CAPS LOCK to the
Here are instructions on how to map your
CAPS LOCK key to either
CTRL for Windows, Mac, and Linux.
In Mac OSX, go to
System Preferences | Keyboard | Keyboard | Modifier Keys and
Caps Lock Key to
Install AutoHotkey and create a new AutoHotkey script by
creating a new file named
Caps2Esc.ahk or right clicking in a folder and choosing
New -> AutoHotkey Script. Inside the script put the following:
Double-click the file or run it directly from the command line to start the script in the background.
To run the script on startup, open the Startup directory by pressing
Windows Key + r and running
shell:startup. Place the AutoHotkey script in there.
In KDE, go to
System Settings | Hardware | Input Devices | Advanced | Caps Lock behavior. From there you can choose either
Make Caps an additional Esc or
Caps Lock is also a Ctrl.
In Gnome desktops this GUI options is available.
sudo apt install dconf-tools dconf-editor
dconf-editor, navigate to
/org/gnome/desktop/input-sources/ and modify
xkb-options value with a settings value from below.
The command-line version is a reliable option as well for Gnome desktops.
# Get current settings first dconf read /org/gnome/desktop/input-sources/xkb-options # Update settings dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:escape']"
These are some of the options you can pass to
xkb-options in the Gnome examples above.
['caps:escape']- Make Caps act like Escape
['caps:ctrl_modifier']- Make Caps act like Ctrl
['ctrl:swapcaps']- Swap Caps and Ctrl
['caps:swapescape']- Swaps Caps and Escape
Notes on VS Code
In Linux, I have had issues with the keybinding being recognized.
To fix this, I modified my
settings.json file to include the following
You should now know how to rebind your CAPS LOCK key to either ESC or CTRL keys in Linux, Mac, and Windows environments.