how to map CTRL with none-letter keys

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

how to map CTRL with none-letter keys

Jeri Raye
Hi

I'm having difficulties with mapping CTRL + none-letter keys

Is it possible to make a mapping for CTRL + the ( character?
Something like
imap <C-(> Hello
This doesn't work for me.

Then I thought apparently shift needs to be added
imap <C-S-(> Hello
This doesn't work either.
How to do that?

And what about mapping CTRL with the char's:
( (opening bracket)
, (colon)
. (dot)
; (semi colon)
| (pipe)

Rgds,
Jeri

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: how to map CTRL with none-letter keys

Taylor Hedberg
You don't mention whether you're using Vim in a terminal or GVim. In a
terminal, this is generally not possible, because typically, terminals
can only receive Ctrl key combinations which have a corresponding ASCII
control character, and none of the characters you listed do.

In GVim, I don't see why this wouldn't work, but I don't use GVim much
so maybe there's an issue I'm overlooking.

attachment0 (853 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: how to map CTRL with none-letter keys

Tim Chase
On 03/27/12 09:21, Taylor Hedberg wrote:
> You don't mention whether you're using Vim in a terminal or GVim. In a
> terminal, this is generally not possible, because typically, terminals
> can only receive Ctrl key combinations which have a corresponding ASCII
> control character, and none of the characters you listed do.
>
> In GVim, I don't see why this wouldn't work, but I don't use GVim much
> so maybe there's an issue I'm overlooking.

I don't think they're available in gvim either.  I just pulled up
gvim (GTK2, v7.2 on Debian Linux) and tried several
unconventional control+{nonalpha char} mapping combinations and
had hit-or-miss results.  If I mapped them by issuing control+V
followed by the character in question, several worked (such as
control+backslash, control+at and control+caret) though I believe
they have ASCII equivs.  None of the other punctuation characters
(comma, period, colon, semicolon, quote, apostrophe, and most of
the other characters over the digits on my US keyboard) worked
with a literal mapping.  Also, none of the attempts to use the
"<c-foo>" notation worked for me such as "<c-bslash>" or "<c-^>"
(both of which worked in mappings created using control+V).

-tim



--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: how to map CTRL with none-letter keys

Yichao Zhou
Yes.  This should really be improved.  In vim, we can not map
<C-Number>, <C-S-Char>.  And we even can not map <C-M> <C-I> since
they are the synonyms of <Tab> and <CR>.  And these combination is
valid on GVim.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: how to map CTRL with none-letter keys

曾波
  some question here, why let <C-J>, <C-H>, <C-M> as <NL>, <BS>, <CR> and so on, can we change it in vim

2012/3/27 Yichao Zhou <[hidden email]>
Yes.  This should really be improved.  In vim, we can not map
<C-Number>, <C-S-Char>.  And we even can not map <C-M> <C-I> since
they are the synonyms of <Tab> and <CR>.  And these combination is
valid on GVim.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php



--
 
 
Thanks and Best Regards!
 

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: how to map CTRL with none-letter keys

Yichao Zhou

We can change C-J C-k but not C-M.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: how to map CTRL with none-letter keys

Tim Chase
On 03/27/12 10:52, Yichao Zhou wrote:
> We can change C-J C-k but not C-M.

Well, you can change C-M, but it also alters the behavior of
hitting <enter> on most platforms.  In Normal mode, this is
fairly benign, since (1) the behavior is duplicated by "+" and
(2) that behavior is pretty rarely used in my experience (outside
of Vimgolf, I almost never use it).   In Insert mode, the use of
<enter> is quite valuable and not worth overloading, IMHO.

-tim



--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: how to map CTRL with none-letter keys

Jan Larres
In reply to this post by Tim Chase
Tim Chase <[hidden email]>:

> I don't think they're available in gvim either.  I just pulled up gvim
> (GTK2, v7.2 on Debian Linux) and tried several unconventional
> control+{nonalpha char} mapping combinations and had hit-or-miss
> results.  If I mapped them by issuing control+V followed by the
> character in question, several worked (such as control+backslash,
> control+at and control+caret) though I believe they have ASCII equivs.
> None of the other punctuation characters (comma, period, colon,
> semicolon, quote, apostrophe, and most of the other characters over
> the digits on my US keyboard) worked with a literal mapping.  Also,
> none of the attempts to use the "<c-foo>" notation worked for me such
> as "<c-bslash>" or "<c-^>" (both of which worked in mappings created
> using control+V).

Actually there is a way to make it work in terminal vim assuming your
terminal allows mapping keys to escape sequences (rxvt-unicode and xterm
do, for example).

Since I like using C-space instead of C-X_C-O for omni-completion I have
the following in my ~/.Xresources:

URxvt.keysym.C-space : \033[?1;32~

And for xterm:

UXTerm*vt100.translations: #override \
    Ctrl <Key>space: string(0x1b) string("[?1;32~") \n

If you're using xterm instead of uxterm then change the 'UXTerm' part to
'XTerm'. Note that these escape sequences are made up by me, the '?' in
them means that they are private use and therefore shouldn't clash with
any standard ones.

Then in my vimrc I have this:

map  <Esc>[?1;32~ <C-Space>
map! <Esc>[?1;32~ <C-Space>

That way the C-Space sequence correctly ends up in Vim. It will of
course only be recognized by Vim, in other applications you will see the
raw escape sequence.

This should work for most keys; it definitely works for characters like
numbers and comma. You can see my complete (slightly more complicated)
configuration here:
https://github.com/majutsushi/etc/blob/master/xorg/Xresources#L182
https://github.com/majutsushi/etc/blob/master/vim/vimrc#L1490

The funny thing is that with this technique it's actually possible to
recognize more character combinations in terminal Vim than in GVim
(unless I'm missing something).

Cheers,
Jan

--
-[ OpenPGP key ID: 00A0FD5F ]-
I distrust those people who know so well what God wants them to do because I
notice it always coincides with their own desires.
                -- Susan B. Anthony

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php