Unfortunately you can't. C-J and/or C-M is the same as Enter. Likewise
C-I is the same as tab, C-[ is the same as Esc. Even in gvim, this is
the case, though more for legacy reasons than because it really has to
be. Hopefully one day it will change. But it needs quite a bit of
development time and effort!
Smiles,
Ben.
Unless I misunderstood, I don't think that was the question, Ben.
The question was not about <C-J> being indistinguishable from <CR>,
but about <C-J> being not mappable at all. Also, at least with my
setup, it's <C-M>, not <C-J>, that's indistinguishable from <CR>.
I can reproduce the OP's observations--that <C-J> is not
mappable--but I have no explanation.
I'm using vim-7.2.22 on a Red Hat Linux system remotely from a
Cygwin rxvt on a Windows XP system.
Regards,
Gary
My apologies. It's possibly related to a similar thing: Vim uses C-J
internally to mean a null byte (which as actually C-@; in fact, in
insert mode, press C-V, C-J and you'll see ^@). Nevertheless, I
have just proven that I can map C-J, both in the terminal and in
MacVim; I thought I'd tried before and I couldn't, but I clearly can
now. Vim 7.2.42. So now I'm baffled as to why it doesn't work for
you...
Can you see the mapping in the output of :map? It does for me, but as
<NL> (newline/null). Can you double check it isn't behaving the same as
Enter by mapping that (<CR>) to something else and checking C-J doesn't
trigger that mapping? Does anything happen if you try to map C-@?! What
do you get in insert mode if you do C-V, C-J? These are just some things
to try...
Ben.
<C-M> is (to Vim) synonymous with <Enter>. If you hit the <Enter> key in
Normal mode, your nmap will be triggered. Similarly, if you happen to
imap <C-M> to something, it will be triggered by hitting <Enter> in
Insert mode, which you probably would want to know before writing any
such mapping.
Best regards,
Tony.
--
When danger reared its ugly head,
He bravely turned his tail and fled
Yes, Brave Sir Robin turned about
And gallantly he chickened out
Bravely taking to his feet
He beat a very brave retreat
Bravest of the brave Sir Robin
Petrified of being dead
Soiled his pants then brave Sir Robin
Turned away and fled.
"Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD