
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
Ctrl
toCmd
- 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
Ctrl
andCmd
via the Keyboard preferences isn’t a straightforward solution, because then using muscle memory forCtrl
codes interminal
andVIM
are now displaced - Another alternative instead of swapping
Ctrl
andCmd
would be to rebind every single possible command, such asCmd
+C
,V
,H
,Q
,T
(and so forth) to useCtrl
instead (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
Caps
lock as a modifier key when pressed with other keys, andescape
when pressed by itself- On windows, I use
Caps
to rebind to theCtrl
modifier when pressed with another key - This allows for
Caps
+C
/V
to copy and paste respectively - However, if in MacOS
Caps
is rebinded toCmd
(via Karabiner elements), then it will work for copy and paste, but then none of theCtrl
modifiers 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
Ctrl
andCmd
****, but altering the behavior of theCaps
modifier so that it sendsCtrl
keycodes 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
→Ctrl
modifier rule, otherwise activate theCaps
→Cmd
rule 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"
]
}
]
}
]
}
]
}