"map <C-J> <C-W>j" not operate...help..

111 views
Skip to first unread message

bsakiag

unread,
Nov 25, 2008, 11:05:54 PM11/25/08
to vim_use
HI,
I'm using split window and navigate windows by mapped key as follow.
--------------------------------------------------------------
map <C-H> <C-W>h
map <C-J> <C-W>j
map <C-K> <C-W>k
map <C-L> <C-W>l
--------------------------------------------------------------

All other mapped key is operate well, but only "<C-J>" key is not
operate. (it's only doing as if I press "return(enter)" in commnd
mode" ==> cursor just moved 1 line below.)

Please let me know how I can use <C-J> navigation maped key..

thanks.

Ben Schmidt

unread,
Nov 26, 2008, 2:57:37 AM11/26/08
to vim...@googlegroups.com
> All other mapped key is operate well, but only "<C-J>" key is not
> operate. (it's only doing as if I press "return(enter)" in commnd
> mode" ==> cursor just moved 1 line below.)
>
> Please let me know how I can use <C-J> navigation maped key..

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.

Gary Johnson

unread,
Nov 26, 2008, 1:17:15 PM11/26/08
to vim...@googlegroups.com

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

Ben Schmidt

unread,
Nov 26, 2008, 5:07:56 PM11/26/08
to vim...@googlegroups.com
Gary Johnson wrote:
> On 2008-11-26, Ben Schmidt wrote:
>>> All other mapped key is operate well, but only "<C-J>" key is not
>>> operate. (it's only doing as if I press "return(enter)" in commnd
>>> mode" ==> cursor just moved 1 line below.)
>>>
>>> Please let me know how I can use <C-J> navigation maped key..
>> 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!
>
> 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.

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.

HyoungJu Lee

unread,
Nov 26, 2008, 8:41:39 PM11/26/08
to vim...@googlegroups.com
Thanks to Ben Schmidt and Gray Johnson.
 
My problem is solved.
In vim input mode, <C-V><C-J> displayed "^M", so I mapped as "nmap <C-M> <C-W>j"
It's works well.
 
Thanks again...

Tony Mechelynck

unread,
Nov 27, 2008, 3:42:23 AM11/27/08
to vim...@googlegroups.com
On 27/11/08 02:41, HyoungJu Lee wrote:
> Thanks to Ben Schmidt and Gray Johnson.
> My problem is solved.
> In vim input mode, <C-V><C-J> displayed "^M", so I mapped as "nmap <C-M>
> <C-W>j"
> It's works well.
> Thanks again...

<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

Reply all
Reply to author
Forward
0 new messages