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?
2
votes
1 Answers
4
votes
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.
- Download and install Seil and Karabiner
- Open Seil and change caps lock to key code 110 (PC Application key)
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
- Check the following items (They should appear at the top of the box)
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>
Ctrl
and edited my question. @Carpetsmoker I tried Seil (the current version of PCKeyboardHack) and it seems that it doesn't have any way of creating application-specific mappings. – Adam Incera