>
> On 25/08/09 19:40, CHEN Cheng wrote:
> >
> > Hi folks,
> >
> > When I map<M-b>, a character "â" shows up, instead of the expected rhs.
> > But, if I map ^]b directly, everything works, which is very interesting.
> >
> > What I did:
> > 1. vim
> > 2. :set<M-b>=^[b
> > 3. :imap<M-b> YYYY
> > 4. i, goto insert mode
> > 5. press<M-b>, nothing happened on the screen
> > 6. press<M-b>, still nothing
> > 7. press<M-b>, character "â" was inserted
> >
> > What I expected:
> > A sequence of YYYY was inserted
> >
> > Workaround:
> > 1. vim
> > 2. :imap ^[b YYYY
> > 3. i, goto insert mode
> > 4. press<M-b>, a sequence of YYYY was inserted
> >
> > Reproduce: everytime
> > 1. Vim 7.1.242
> > 1.1 set esckeys
> > 2. Linux, Fedora Core 7
> > 2.1 Virtual Terminal, TERM=linux
> > 2.2 setmetamode esc
> >
> > It seems vim treats assigned<M-b> and ^]b differently, but actually
> > <M-b> has the value of ^]b. Is it a contradiction?
> >
> > Note: ^]b is a sequence of escape and letter "b".
> >
> >
> > Thanks in advance,
> > Cheng
>
Hi Tony, thanks for your response.
> - See ":help :map-alt-keys"
>
> - Since, to Vim, [key + 0x80] is equivalent to [Meta+key], Alt-b (where
> b is 0x62) will be stored in mappings as 0xE2, i.e., â (small Latin a
> with circumflex).
>
> - I don't think 'esckeys' applies to <M-...> (but I could be wrong).
>
> - IIUC, your "setmetamode esc" is the culprit. Try
>
> setmetamode bit
>
I tried 'bit' but failed. Please see the test record I made below:
|-------------------+------------+-----+-----+-----------+-----+-----|
| terminal / config | SendEscape | | | 8bit_meta | | |
|-------------------+------------+-----+-----+-----------+-----+-----|
| vim mapping | <M-b> | ^]b | cat | <M-b> | ^]b | cat |
| and cat test | | | | | | |
|===================+============+=====+=====+===========+=====+=====|
| xterm $TERM=xterm | â | ok | ^]b | ok | â | â |
|-------------------+------------+-----+-----+-----------+-----+-----|
| gnome-terminal | | | | no 8bit |
| $TERM=xterm | â | ok | ^]b | mode |
|-------------------+------------+-----+-----+-----------+-----+-----|
| Linux virtual | | | | | | |
| terminal (VT) | â | ok | ^]b | â | â | â |
|-------------------+------------+-----+-----+-----------+-----+-----|
| putty | | | | |
| $TERM=xterm | â | ok | ^]b | no test |
|-------------------+------------+-----+-----+-----------+-----+-----|
Note: the listed terminals are configured into two modes, escape meta
mode and 8bit meta mode, respectively. For each mode, the output
after pressing Alt-b is shown in three settings:
<M-b> :set <M-b>=^]b before :imap <M-b> ok
^]b :imap ^]b YYYY directly
cat not in vim, but in stdin, which is provided by
executing 'cat' in the shell
Note: the tests are done in `LANG=en_US.UTF-8 vim`.
As you see, in 8bit mode (linux console), "â" is what I always get.
> instead. Vim "ought" to recognise this with no problem; however, when I
> do that on a Linux terminal here, Vim requires pressing the key between
> three and five times (i.e., press Alt, hit aaa, release Alt; or press
> Alt, hit zzzzz, release Alt) before it notices that I've done anything.
>
> With "setmetamode esc", Vim sees the Esc+something immediately, but as
> Esc followed by something else, not as an Alt-key combo. In Insert mode
> I get nothing, or maybe a beep, etc., depending on which key was used
> with Alt; and if prefixed by Ctrl-V I see ^[a ^[b ^[c etc. instead of á
> â ã (a-acute a-circumflex a-tilde) which are correct for Alt-a Alt-b
> Alt-c respectively.
>
> I don't know why you saw â and not YYYY when hitting Alt-b repeatedly
> after doing
>
> :set <M-b>=^[b
> :imap <M-b> YYYY
>
> where ^[ is entered by hitting Ctrl-V followed by Esc, or (alternately)
> ^[b by hitting Ctrl-V followed by Alt-b. When I do it (in that order,
> and when Vim was started in a linux console on /dev/tty3 just after
> using "setmetamode esc"), I see YYYY. (I'm using a "Huge" Vim 7.2.245 on
> openSUSE Linux 11.1.) For me (where it works) it wouldn't be practical
> since it would mean using twice as many "set" statements as there are
> "printable" keys on my keyboard -- one for each unshifted meta+key and
> one for each shifted meta+key.
>
Aha, your experiment made me blame the difference between your box
and mine. Suddenly, an idea came out, which asked me to check $LANG.
I did:
$ LANG=C vim
Guess what? I reproduced your experiment. I also see YYYY!!!
But, when I:
$ echo $LANG
en_US.UTF-8
$ vim
Oops, "â" came out as before.
So, for vim, the problem might be utf8 support conflicting with
meta key handling.
Since I use the Chinese language, I can't set encoding to latin1, which
turns Chinese characters into a mess.
I think I'd better live with escape meta key mode, because gnome-terminal
supports Chinese well, but it doesn't support 8bit meta key mode.
Best regards,
Cheng
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment