what's a good way for vim to have that when you ssh into a remote box? Would you do the rebinding in the Terminal app or something, agent forwarding or something similar?
I ssh into newly provisioned boxes regularly to edit some config files so I'd need something that works not just locally...
The remap is at the OS level, so if you remap caps lock to control or escape, that's what your machine will send over SSH when you press it. No need to change for every terminal app you use.
Standard key mappings are performed by the OS of the computer to which your keyboard is connected (either physically or via bluetooth or some such). When you press caps lock, the OS sees a caps lock keypress, but any application programs on your computer, including terminal, will see only an ESC keypress. Terminal will dutifully send the ESC press to the ssh program running in Terminal, which in turn should send it along to the remote host into which you are ssh'd.