I am encountering some strange behavior with a keymap in vim that uses the ctrl key. I would guess that this has a simple cause and solution, but I just can't see it.
During the editing of restructuredtext, I find myself typing things like
:math:`x`
often (this :math: role will cause whatever is inside the ticks to be typeset as math in e.g. the latex output).
I want to map a key like m to enter :math:`` into the text and position the cursor inside the ticks.
I have done this
map m i:math:``ha
and that seems to work fine.
However, I would like to be able to use this map in insert mode. For that, I thought that using ctrl+m would be best. I've done
imap <c-m> :math:``ha
Although that correctly inputs :math:`` and positions the cursor inside the ticks when I do ctrl+m, the trouble is that after this point, every time I press enter in insert mode, it runs the same command as if I typed ctrl+m. In other words, enter in insert mode now seems to be mapped to
:math:``ha
as well.
It seems like it is definitely something to do with using the ctrl key. If I bind e.g. the F5 key as follows
imap <F5> :math:``ha
everything is fine.
I can use the e.g. F5 key and save myself any further bother, but I would like to know what is going on for future reference.
Is there something basic about the use of the ctrl key in a key map that I am missing?
thank you,