How to map key shift+ctrl+N?

2,567 views
Skip to first unread message

Peng Yu

unread,
Jul 7, 2008, 11:21:19 PM7/7/08
to vim_use
Hi,

Currently, I have the following key mapping in my .vimrc. I'm
wondering how to map it to a key combination shift+ctrl+N.

Thanks,
Peng

map <F5> <ESC>:!gnome-terminal &<kEnter>

Tony Mechelynck

unread,
Jul 8, 2008, 12:09:26 AM7/8/08
to vim...@googlegroups.com

Vim cannot tell apart Ctrl-n and Ctrl-shift-n, they both resolve to
ASCII 0x0E. If I were you I would stick with F5.

Best regards,
Tony.
--
Ever notice that even the busiest people are never too busy to tell you
just how busy they are.

Peng Yu

unread,
Jul 8, 2008, 5:42:30 PM7/8/08
to vim_use


On Jul 7, 11:09 pm, Tony Mechelynck <antoine.mechely...@gmail.com>
wrote:
Hi,

vim-latex remap F5 to something else. That is why I want to map the
above command to other key combination. Can you just let me know who
to map ctrl-n? The difference between Ctrl-n and Ctrl-shift-n can be
told my other programs such as genome-terminal. Is it possible to make
gvim be aware the difference between such key combinations?

Thanks,
Peng

Benjamin Fritz

unread,
Jul 8, 2008, 5:57:06 PM7/8/08
to vim...@googlegroups.com

CTRL-N and CTRL-n both send the same ASCII code, which is what Vim
uses to determine what key is pressed. So no, Vim cannot tell the
difference.

ALT-N and ALT-n send different codes however, so you could use <m-N>
or <a-N> as the mapping's LHS. If you use alt mappings with gvim, you
may need to mess with the winaltkeys option.

Note that <F5> and <S-F5> are also distinguishable by Vim if you want
to go that route.

Tony Mechelynck

unread,
Jul 8, 2008, 9:32:52 PM7/8/08
to vim...@googlegroups.com

Ctrl-N is shown as <C-N> in mappings. In Normal mode it is an alias for
j so you can afford to remap it, but in Insert mode it is used for
"Next" in Insert-mode completion.

Similarly you can use <S-F5> for shift-F5, <M-C-End> for Ctrl-Alt-End
(where M- means "meta" and is equivalent to A-) etc.

See ":help keycodes", near the end of the list.

AFAIK, gvim cannot be made aware of the difference between Ctrl-N and
Ctrl-Shift-N: it's part of the ASCII representation of control
characters, where "Ctrl+lowercase letter" and "Ctrl+uppercase letter"
both map to "letter code AND 0x1F", obliterating the 0x20 case difference.


Best regards,
Tony.
--
If you wish to live wisely, ignore sayings -- including this one.

John Beckett

unread,
Jul 9, 2008, 5:51:33 AM7/9/08
to vim...@googlegroups.com
Tony Mechelynck wrote:
> AFAIK, gvim cannot be made aware of the difference between Ctrl-N and
> Ctrl-Shift-N: it's part of the ASCII representation of
> control characters, where "Ctrl+lowercase letter" and
> "Ctrl+uppercase letter"
> both map to "letter code AND 0x1F", obliterating the 0x20
> case difference.

For the OP:
And the reason for the limitation is that Vim is designed to operate on an amazingly
large number of different systems. Only a small number of systems provide a way for
an app to learn the difference between Ctrl-N and Ctrl-Shift-N.

John

Reply all
Reply to author
Forward
0 new messages