When editing code with Vim, the ESC and CTRL key are used frequently, but these two keys are far from the home row, so I want to map the CapsLock key to the Esc or Ctrl to make hand more comfortable.
Even, a better approach is to map CapsLock to both ESC and CTRL at the same time, tap for ESC and hold for CTRL.
On my system, macOS, Karabiner-Element is a useful tool to remap the keys. Install it through downloading the install package from official site, or the way I prefer is through homebrew, brew install --cask karabiner-elements
, then import the configuration from here.
Remember open this application before you import the configuration, to make sure you give it the necessory permissions.
References: