Re: Windows vista alt key mapping

2009-08-16 Fir de Conversatie Tony Mechelynck

On 09/08/09 08:17, Ian00 wrote:

 What does set enc? fenc? fencs? print out if you
 put it in _vimrc?  If you run that line manually?

 Looks like you were on to something.
 fenc=utf-8
 enc=utf-8
 fencs=ucs-bom,utf-8,default,latin1

 In my .vimrc, I had this
 set encoding=utf-8
 when I put the the keymaps after that line in .vimrc, they work,
 before that line, they don't work. Without that line, they work.

See the first NOTE under :help 'encoding', where the existing text 
in Vim refers to _all_ text in Vim memory, not only files being edited, 
but also mappings and options.

When you set 'encoding' to UTF-8, any preexisting mappings and options 
(and edited text, but in your vimrc the editfile is normally not yet 
loaded) whose values include characters above 0x7F (including Alt key 
combos, because Vim represents the Alt key modifier by setting the 0x80 
bit) become invalid, because any character above 0x7F requires at least 
two bytes in UTF-8. Defining your mappings after setting 'encoding' to 
UTF-8 takes care of that, and represents e.g. Alt-a (or a-acute, see 
below) as U+00E1, or internally as 0xC3 0xA1. Before you change 
'encoding', it is still set to your locale's default -- probably 
Windows-1252, in Western countries on Windows, which would mean Alt-a 
= á = 0xE1 (one byte in memory).

This high-bit representation also explains what you saw:

a = 0x61Alt-a = 0xE1 = á
b = 0x62Alt-b = 0xE2 = â
c = 0x63Alt-c = 0xE3 = ã
...etc...
x = 0x78Alt-x = 0xF8 = ø
y = 0x79Alt-y = 0xF9 = ù
z = 0x7AAlt-z = 0xFA = ú

Note that Vim can never see any difference between these Alt combos and 
the corresponding accented letters. If you use Alt-a as the {lhs} of a 
mapping, a-acute will also trigger that mapping, and vice-versa.

Note also that unlike with Ctrl, Alt does not swallow Shift: Alt-a is 
not the same as Alt-A (which is Alt-Shift-a).


Best regards,
Tony.
-- 
The only thing to do with good advice is pass it on.  It is never any
use to oneself.
-- Oscar Wilde

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



Windows vista alt key mapping

2009-08-08 Fir de Conversatie Ian00

This looks like a bug that I've worked around. I've noticed in windows
vista that mapping alt keys doesn't work in ~/.vimrc. Mapping after
vim loads works fine, and creating a separate file with the mappings
and then sourcing it from an autocommand works:

autocmd VimEnter * source ~/.vimbugfix

For reference, alt a-z in insert mode gives:
áâãäåæçèéêëìíîïðñòóôõö÷øùú

I get the same result with default settings, and no vimrc or gvimrc.

- Ian Kelling

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



Re: Windows vista alt key mapping

2009-08-08 Fir de Conversatie Matt Wozniski

On Sat, Aug 8, 2009 at 4:49 AM, Ian00 wrote:

 This looks like a bug that I've worked around. I've noticed in windows
 vista that mapping alt keys doesn't work in ~/.vimrc. Mapping after
 vim loads works fine, and creating a separate file with the mappings
 and then sourcing it from an autocommand works:

        autocmd VimEnter * source ~/.vimbugfix

 For reference, alt a-z in insert mode gives:
 áâãäåæçèéêëìíîïðñòóôõö÷øùú

 I get the same result with default settings, and no vimrc or gvimrc.

 - Ian Kelling

Hm.  Don't have a windows machine to test with at the moment, care to
do some debugging?  What does set enc? fenc? fencs? print out if you
put it in _vimrc?  If you run that line manually?  If you put the maps
in _vimrc, what shows up for them in the output of the :map command?
My wild guess is that the encoding when the vimrc is being sourced
doesn't match the encoding you get once vim is started, and that's
causing vim to map one set of byte sequences for A-x in vimrc and
another set once vim has started.  If I'm right, you might be able to
fix it using either a scriptencoding in the vimrc (but probably
not), or by setting encoding in your vimrc.

~Matt

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