Saturday, January 2, 2010

Re: mapping problems

On 02/12/09 19:59, Ben Fritz wrote:
>
>
> On Dec 1, 1:39 pm, Matt Brown<deadguysf...@gmail.com> wrote:
>> <C-S-i> or<S-C-i> or<S-Tab>: the mapping shows up in my map, but there is
>> an additional new mapping for<C-i> (which is the same as<Tab>). After I
>> unset that the<C-i> mapping, the<C-S-i> map remains but does not work. It
>> seems vim does not differentiate between<C-S-i> and<C-i>.
>>
>> <C->> or<C-S-.>: Again, the mapping shows up in my map, but vim seems to
>> be losing the CTRL. In insert mode, a> is inserted into the buffer.
>> <C-<> or<C-S-,>: Same as above.
>>
>
> Vim cannot distinguish between the ctrl- and the ctrl-shift version of
> printable characters. IIUC some GUI-enabled Vims might be able to but
> I have never had this luck.
>
> ALT mappings can be case-sensitive however.
>
> This is a limitation of the way Vim handles keyboard events. You won't
> be able to get around it.
>

Yes, and in addition, not every printable character can have its Ctrl
counterpart recognized. The only "Ctrl + printable key" combinations
which Vim can reliably recognize are those defined by ASCII, as follows:

if x is a printable ASCII character with hex representation 0xhh: if hh is

3F (question mark): Ctrl-? is 0x7F (DEL)
40 to 5F (at-sign, uppercase A to Z, left-bracket, backslash,
right-bracket, spacing-circumflex and underscore, in that order):
subtract 0x40 to get Ctrl-x
61 to 7A (lowercase a to z): Ctrl(x) == Ctrl(upcase(x))

Other Ctrl-printable combinations are not portable, and usually not
recognized.

The above explains why Ctrl-I and Tab (0x06) are synonymous, and also
Ctrl-[ and Esc (0x1B), Ctrl-M and Return (0x0D), etc.

Also, on keybords other than US-QWERTY, the characters @[\]^_ may or may
not be on the same key as their Ctrl counterparts, or some of these
"Ctrl combinations" may sometimes simply not be present on the keyboard,
or require an organist's dexterity to produce chords between some key
and one or more of Ctrl, Shift and AltGr. However, even keys not present
on the keyboard can be used in the {rhs} of a mapping. (Vim will accept
them in the {lhs} too but of course, there they are rather useless,
except maybe when mappings are "remapped".)

For instance, on my Belgian keyboard I use

:map <F9> <C-]>

so I can follow the hotlinks of the Vim help by means of F9 rather than
Ctrl-AltGr-$ which is not really easy to key.


Best regards,
Tony.
--
Ken Thompson has an automobile which he helped design. Unlike most
automobiles, it has neither speedometer, nor gas gage, nor any of the
numerous idiot lights which plague the modern driver. Rather, if the
driver makes any mistake, a giant "?" lights up in the center of the
dashboard. "The experienced driver", he says, "will usually know
what's wrong."

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment