MacOS & Windows muscle memory keybindings
Productivity
Tools
MacOS
Power at your fingertips
- When switching between MacOS and Windows, the keyboard position for shortcuts such as copy and paste are switched from
CtrltoCmd- Since these are in different places on the keyboard, user needs to press a different key on the keyboard, which interferes with muscle memory
- Simply swapping
CtrlandCmdvia the Keyboard preferences isn’t a straightforward solution, because then using muscle memory forCtrlcodes interminalandVIMare now displaced - Another alternative instead of swapping
CtrlandCmdwould be to rebind every single possible command, such asCmd+C,V,H,Q,T(and so forth) to useCtrlinstead (via Keyboard preferences)- This solution is overly cumbersome and every single possible combination would have to be considered one-by-one
- This conundrum also applies to using the
Capslock as a modifier key when pressed with other keys, andescapewhen pressed by itself- On windows, I use
Capsto rebind to theCtrlmodifier when pressed with another key - This allows for
Caps+C/Vto copy and paste respectively - However, if in MacOS
Capsis rebinded toCmd(via Karabiner elements), then it will work for copy and paste, but then none of theCtrlmodifiers for Vim such asCtrl+U(undo) orCtrl+C(break) will work in terminal.
- On windows, I use
- The best solution I’ve found so far, is NOT swapping
CtrlandCmd****, but altering the behavior of theCapsmodifier so that it sendsCtrlkeycodes in Terminal based apps such as iTerm and VS Code, otherwise by default sendCmd****.- This is done by setting the logic based on the active foreground app: if the foreground app is a terminal based app, then activate the
Caps→Ctrlmodifier rule, otherwise activate theCaps→Cmdrule by default.
- This is done by setting the logic based on the active foreground app: if the foreground app is a terminal based app, then activate the
My Karabiner JSON config
- To add or remove apps, modify
bundle_identifiers - Can find bundle_identifier by:
osascript -e 'id of app "Name of App"' - Can use Karabiner Complex Modification tool, or edit JSON file directly (examples below used the modification tool)
{
"title": "Change caps_lock to command",
"rules": [
{
"description": "Change caps_lock to Command if pressed with other keys, to escape if pressed alone.",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "caps_lock",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_command"
}
],
"to_if_alone": [
{
"key_code": "escape"
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.microsoft\\.VSCode",
"^com\\.googlecode\\.iterm2"
]
}
]
}
]
}
]
}
{
"title": "Change caps_lock to CTRL",
"rules": [
{
"description": "Change caps_lock to CTRL if pressed with other keys, to escape if pressed alone. (APP SPECIFIC)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "caps_lock",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_control"
}
],
"to_if_alone": [
{
"key_code": "escape"
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"com\\.microsoft\\.VSCode",
"com\\.googlecode\\.iterm2"
]
}
]
}
]
}
]
}
