Search code examples
vimkeymapping

vim key mapping being fired by carriage return


I use gvim on windows 10 and am trying to get a good keymap to open a vertical split to a new file. I first tried

nnoremap <c-m><c-m> :vnew<CR>

but for some reason if I hit carriage return twice in succession in normal mode, I would get a new vertical split window. So I took the trailing carriage return out of the key map

nnoremap <c-m><c-m> :vnew

and still get a new vertical split window if I hit carriage return three times in normal mode, which for some reason I find myself doing.

Why is carriage return setting off the key map when there isn't even a carriage return in the key map in _vimrc? I have restarted vim with no effect.


Solution

  • From Vim's point of view, <C-m> is <CR> and <CR> is <C-m>.

    They are the same key so you can't map something to <C-m> without mapping it to <CR> and vice-versa.

    You'll need to find another key combo for your mapping.