In order for a mapping to work, Vim has to recognise the keycodes that your terminal is sending. To find out what your terminal is sending, try typing the following to enter insert mode and insert the keycode into the current buffer:
iCtrl-VCtrl-,
If a regular comma is inserted, then this is what your terminal is sending to Vim, and there is no way to map <C-,>
separately without reconfiguring your terminal to send something else instead.
If some other sequence of characters is inserted, then you can create a mapping by using the same Ctrl-VCtrl-, keystrokes to enter this sequence of characters as the lhs
of your mapping (in place of the <C-,>
you tried.
If nothing is inserted, then your terminal isn't sending anything to Vim when you press Ctrl-,. Again, you will need to reconfigure your terminal in order to use this key combination in Vim.
Further Details
If you are wondering why your terminal might send a comma when you Ctrl-,, you need to understand how the Ctrl key actually works within terminals.
Historically, the Ctrl key was used to enter the Control Characters that make up the first column of an ASCII table. It worked by clearing the 6th and 7th bits of the keycode generated by the key normally. So pressing the Ctrl key when you press L
converts binary 11 01100
into binary 00 01100
or an FF
(form feed).
However, take a look at the other entries in the same row as FF
and <C-l>
. Clearing the 6th & 7th bits of these will also result in a FF
. So <C-L>
is identical to <C-S-L>
and, notably for your purposes, <C-,>
.
It's not especially useful to have three separate keychords all map to the same control character, so, when pressing Ctrl along with a character in the second column — such as the comma — most terminal emulators either send the character unmodified, or map it to some other sequence of characters.