Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping <Ctrl-Ctrl> to ESC in VIM

Tags:

vim

tmux

On OS X, I've changed Caps-Lock to CTRL in the Keyboard Modifier settings. It's great, but I'd like to use CTRLCTRL (a quick double-tap) to ESC in VIM (my pinky is resisting CTRL[). Possible?

Already using au CursorHoldI * stopinsert and set ut=2000 to exit Insert Mode after two seconds, but some plugins interfere (completion, most often).

Aside: Could this, if possible, create a conflict with Tmux?

like image 737
Joshua Berk Avatar asked Jul 16 '14 00:07

Joshua Berk


2 Answers

You cannot map Ctrl by itself in Vim at all, let alone CtrlCtrl. It is strictly a modifier key.

like image 85
Amadan Avatar answered Oct 05 '22 22:10

Amadan


As @echristopherson mentioned, Karabiner can do some serious remap wizardry…
Jumping off his suggestion, I found the Karabiner documentation and came up with:

<?xml version="1.0"?>
    <root>
    <item>
        <name>Ctrl Freak</name>
        <identifier>private.double_ctrl_to_escape</identifier>
        <autogen>
            __DoublePressModifier__
            KeyCode::CONTROL_L, KeyCode::CONTROL_L,
            KeyCode::ESCAPE
        </autogen>
    </item>
</root>

I have done some quick testing with it, but from first blush, seems to perform without issue on OSX, SUBLIME TEXT, and VIM (within a TMUX session).

Keep in mind:
This is a system wide solution though. For me, that's a good thing. I use a 60% keyboard and need to make the most of my real estate.

For a VIM specific solution:
You will need to add that bit. The documentation can be found here.

Cheers!

like image 25
visyoual Avatar answered Oct 05 '22 22:10

visyoual