2
votes

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?

1
Possible duplicate: Using Caps Lock as Esc in Mac OS XmMontu
This answer seems to do what you want?Martin Tournoij
Just realized I actually definitely would like to to map it to 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
Terminal vim or macvim. It is probably easier to do in macvim then Terminal vim. (Probably almost impossible for it to behave nicely with terminal vim)FDinoff
@FDinoff Oh dear. I was hoping for Terminal vim...if I could create an app-specific mapping for all of Terminal, would that do it? That would be fine with me.Adam Incera

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.

  1. Download and install Seil and Karabiner
  2. Open Seil and change caps lock to key code 110 (PC Application key) caps lock to key code 110
  3. 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>
    
  4. Click Reload XML on the Change Key tab

  5. Check the following items (They should appear at the top of the box) Enable capslock

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>