How to map CAPS LOCK key in Vim?
If you are using the X11 environment, you may achieve what you want
with the following commands:

xmodmap -e 'clear lock'


which means: from now on, Caps_Lock key isn't anymore a keyboard modifier
and fall back to a normal key

xmodmap -e 'keysym Caps_Lock = Escape'


which means: get the keycode of Caps_Lock and from now on assign it the
keysym of Escape.

Note: this receipe works on any Unix.