Why is so complicated to remap Esc to CAPS LOCK in Vim?
There's no vim key identifier for the capslock key, so you have to do it with a scan code.
It would be like trying to map the ctrl key or the shift key to something - those keys don't do anything by themselves, they are key modifiers, so they can't be trapped the same way.
Also you can try this: SharpKeys. I swaped CapLock and Esc with it.
The mapping has to be done at the OS level instead of vim, so the complication comes from the OS. For example, on my Ubuntu machine I have the following in ~/.Xmodmap
:
! Esc on caps lock
remove Lock = Caps_Lock
keysym Caps_Lock = Escape
However, I don't think the REGEDIT script is so bad. It's kind of ugly, but it's only two lines!
I recommend that you use AutoHotkey for this.
You can do a per-application hotkey change:
SetTitleMatchMode,2
#IfWinActive,VIM
CAPSLOCK::ESC
return
#IfWinActive
CAPSLOCK::CTRL
return
This script, for example sets caps to escape in vim, and control everywhere else.