Wednesday, August 1, 2012

Re: Difference between and

On 01/08/12 03:12, JaredPar wrote:
> The help page on key-notation (:help key-notation) states that several keys are equivalent for others
>
> - <C-H> and <BS>
> - <C-I> and <Tab>
> - <C-L> and <FF>
>
> For most keys this appears to be true. Attempts to map with the LHS of <C-I> and <Tab> would conflict and the last one typed would win. For example
>
> :imap <Tab> hit tab
> :imap <C-I> hit control i
> :imap
>
> This will actually print the following.
>
> i <Tab> hit control i
>
> This behavior is expected. The keys are equivalent and hence the latter mapping should win out exactly as if I had typed <Tab> in the second mapping. This behavior appears to play out for 6 of the 7 equivalent key pairs listed on that page.
>
> It doesn't play out though for <C-H> and <BS>. These appear to be different keys even though they have the same ASCII value
>
> :imap <C-H> hit control h
> :imap <BS> hit backspace
> :imap
>
> This will print both mappings out to the screen. Subsequent key strokes of <C-H> and <BS> will insert the expected value into insert mode.
>
> Why is the <C-H> and <BS> pair different in this respect? I can't seem to find any justification for this difference?
>
> I'm using gVim 7.2 on Windows (7 or server 2008).
>

Vim can also tell <Del> and <C-?> apart (at least in my GTK2 GUI). I
think it's because on some systems the backspace key in "cooked" mode
produces ^H (0x08) and the Del key ^? (0x7F), and on other systems it's
the opposite, so Vim needs some fancy footwork to keep them straight.
See among others :help :fixdel

This varies between gvim and Console Vim: the same executable running in
Console mode in the Linux (text-only) console or in the KDE konsole sees
<BS> as ^? and <Del> as ^[[3~ which I suppose means that it cannot tell
Backspace apart from Ctrl-? (in GUI mode it can). (NB. On Linux, but not
on Windows, it is possible to have a single executable for both gvim and
Console Vim, and that's what I'm using.)

Note that (something + 0x80) is also equivalent with (Alt-something)
where "something" is any keycode in the range [0x00-0x7F]. For instance
(in Latin1 or UTF-8 'encoding') 0xE9 is both é (e-acute) and Alt-i.

Oh, and BTW, Vim 7.2 is old stuff: Vim 7.3.0 was released about two
years ago and 7.3.618 came out day before yesterday. I recommend that
you upgrade to a more recent version, e.g. by installing the most recent
"Vim" (not "cream") installer found at
http://sourceforge.net/projects/cream/files/Vim/ (as of this writing
it's 7.3.600 but if by the time you get there there is a more recent
version, so much the better).


Best regards,
Tony.
--
How wonderful opera would be if there were no singers.

--
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

No comments: