Remap Caps Lock for the Vim-pilled.
Caps Lock is in the best position on your keyboard and does the worst job. We're going to fix that — one key that acts as Control when held and Escape when tapped.
Why this matters
In Vim, you hit Esc and Ctrl dozens of times per minute. They live in the worst places on the keyboard. Caps Lock lives in the best place on the keyboard and does nothing useful. Remapping it is the single highest-leverage tweak you will ever make.
Choose your OS
Pick your platform below. The instructions in section 03 will switch to match.
Follow the steps
- 01
Install Karabiner-Elements
Karabiner-Elements is a free, open-source keyboard customizer for macOS. Native macOS can map Caps Lock to Control via System Settings, but it can't do hold-vs-tap — that's the whole reason we need Karabiner. Skip the System Settings remap; Karabiner handles everything.
Download the installer from the official site and run it. You'll need to grant it Input Monitoring access on first launch (System Settings → Privacy & Security).
- 02
Add the Complex Modification rule
Open Karabiner-Elements → Complex Modifications tab → Add predefined rule → Import more rules from the Internet, or paste the rule below directly into your config file.
// ~/.config/karabiner/karabiner.json{ "description": "Caps Lock → Ctrl (hold) / Esc (tap)", "manipulators": [{ "type": "basic", "from": { "key_code": "caps_lock" }, "to": [{ "key_code": "left_control" }], "to_if_alone": [{ "key_code": "escape" }] }] }The
to_if_alonefield is what makes hold-vs-tap work: hold the key and Karabiner sends Control; tap and release within ~250ms and it sends Escape instead.
- 01
Install keyd
keyd is a small daemon that handles hold-vs-tap on every Linux display server. The package is only in official repos on bleeding-edge distros — most users will need a PPA or the source build.
// Debian / Ubuntu (LTS) / Mint# keyd is in apt only on Ubuntu 25.04+ / Debian 13+. # For 22.04, 24.04, or Debian 12, use the maintainer PPA: sudo add-apt-repository ppa:keyd-team/ppa sudo apt update && sudo apt install keyd// Arch / Manjaro / EndeavourOSsudo pacman -S keydFor Fedora, openSUSE, RHEL, or any other distro without a package, follow the build-from-source instructions — it's a 30-second compile (
make && sudo make install). - 02
Configure the remap
Create
/etc/keyd/default.confwith the following content. Theoverloadaction gives you Ctrl when held and Esc when tapped — exactly what we want.// /etc/keyd/default.conf[ids] * [main] capslock = overload(control, esc) - 03
Enable the daemon
Run
sudo systemctl enable --now keyd. After it starts, test it: holding Caps Lock should send Ctrl, tapping it should send Esc. Reload at any time withsudo keyd reload.
- 01
Install AutoHotkey v2
Get AutoHotkey v2 from the official site. AHK can intercept Caps Lock directly — no PowerToys needed, and unlike a
*LCtrl::hook it won't interfere with your real Ctrl key. - 02
Save the script and run it at login
Save the file below as
caps-vim.ahk, then press Win+R, typeshell:startup, and drop the file into the Startup folder so it launches with Windows. Double-click it once to start it now without logging out.// caps-vim.ahk; Caps Lock → Ctrl (hold) / Esc (tap). *CapsLock:: { Send "{LCtrl Down}" startTime := A_TickCount KeyWait "CapsLock" Send "{LCtrl Up}" if (A_TickCount - startTime < 200 && A_PriorKey = "CapsLock") Send "{Esc}" }The script measures the press duration with
A_TickCount— anything under 200ms counts as a tap and fires Escape on key-up; anything longer was a hold and stays as Ctrl. The CapsLock LED may still flash briefly on tap depending on your keyboard firmware; that's cosmetic, AHK has already swallowed the keypress.
Verify it works
Open a terminal and run through this checklist. Every line should produce the marked behaviour. If any one fails, the daemon (keyd / Karabiner / AHK) probably isn't running — check it before retrying.
$ tap caps lock // nothing happens — no CAPS LOCK light $ hold caps lock + C // ✓ sends Ctrl+C $ open vim, press i then tap caps // ✓ exits INSERT mode // if any step fails, check that keyd / karabiner / ahk is running
Was this guide useful? One tap, no signup needed.
New keybinding → new muscle memory.
Reading only gets you so far. Your fingers need reps.