How to map Command key to Control key when using vscode
I already mapped "Caps Lock" key to "Command" key using System Preferences of macOS, as I use "Command" key frequently when using most application.
When using vscode with vim keymap, I use "Control" key at most time. Is it possible to map "Command" key (actually the "Caps Lock" key in keyboard) to "Control" when using vscode?
In Vim 8.2 :help <D- shows that mappings can be defined for the Command key. Not sure if that helps.
(By the way, one thing I loved about using VSCodeVim is that when I switch between macOS and Linux, the Vim keyboard shortcuts stay the same!)
I have the same requirement, has anyone solved it?
Things I tried which didn't work:
"vim.normalModeKeyBindings": [
{
"before": ["<Cmd>"],
"after": ["<Ctrl>"]
}
]
"vim.normalModeKeyBindings": [
{
"before": ["<D>"],
"after": ["<C>"]
}
]
There is a Mac app called "Karabiner" (latest version "Karabiner Elements") which might be able to help you.
I know it can switch Cmd and Ctrl. But can it do it just for one specific app? Perhaps...
Unfortunately Karabiner do not have a feature change the function of keys for specific app.
Unfortunately Karabiner do not have a feature change the function of keys for specific app.
Karabiner does allow you to set conditions, including limiting the rule to specific apps. It will affect absolutely everything (including ⌘-tab, etc), so you might want to refine this a bit, but the following complex modification works for me:
{
"description": "Map command to control in VS Code",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com.microsoft.VSCode"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "left_command"
},
"to": [
{
"key_code": "left_control"
}
],
"type": "basic"
}
]
}
Is there any simple solution to this problem in 2024?