3

I have the mapping shown below, in my ~/.vimrc. However, this mapping also hijacks the Enter key. So, whenever I hit Enter it executes the tabedit % command. I am using gvim 7.3

nnoremap <C-m> :tabedit %<CR>

Can anyone fix this so that it doesn't hijack the Enter key.

1 Answer 1

4

< C-m> maps to the enter key (C-M and CR both do); it's not hijacking it, you're telling it to run :tabedit % every time you hit enter. I would suggest a different mapping.

See :h key-notation for more information.

3
  • How come? the vim documentation says that <C-...> is the control-key so <C-m> should map to Ctrl+M shouldn't it? I tried changing the mapping to use <C-x> and it doesn't seem to have that issue anymore. But I am still confused. Commented Jun 21, 2012 at 12:30
  • Control+M also acts as an enter key, but it's not the only redundancy. Control+[ corresponds with ESC. Control+I, tab. See :h key-notation. Commented Jun 21, 2012 at 12:45
  • Thanks, it all makes sense now. I ended up mapping <C-n> for this. Commented Jun 21, 2012 at 13:39

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.