Reputation: 117
I'd really like to be able to map the caps lock key to Ctrl
, but only in vim. I saw this, but I'm using OS X. Is there an OS X alternative to AutoHotKey, or is there another way to create an application-specific mapping for a modifier key?
Upvotes: 2
Views: 2252
Reputation: 31429
This will change caps lock to control in Terminal. I don't believe there is a good way to tell when Terminal is running vim.
Open Karabiner and edit private.xml (Misc & Uninstall (Tab) -> Open Private Xml (Button)). Add add the following between the root elements.
<name>Change PC Application Key to CONTROL (Menu Key in TERMINAL)</name>
<item>
<only>TERMINAL</only>
<name>Change PC Application Key to CONTROL (Menu Key in TERMINAL)</name>
<identifier>remap.termianl_application2control</identifier>
<autogen>__KeyToKey__ KeyCode::PC_APPLICATION, KeyCode::CONTROL_L</autogen>
</item>
<name>Change PC Application Key to CAPSLOCK</name>
<item>
<name>Change PC Application Key to CAPSLOCK</name>
<identifier>remap.other_application2capslock</identifier>
<autogen>__KeyToKey__ KeyCode::PC_APPLICATION, KeyCode::CAPSLOCK</autogen>
</item>
Click Reload XML on the Change Key tab
At this point you should be able to use caps lock as control in terminal (and iterm2) and caps lock as caps lock every where else. Caveat, If you go into terminal when caps lock is on you won't be able to shut it off.
(You might need to set CapsLock to No Action in System Preferences -> Keyboard -> Modifier Keys)
If you want this to also work in MacVim change
<only>TERMINAL</only>
to
<only>TERMINAL, VI</only>
Upvotes: 4