On 24/08/13 21:22, [email protected] wrote:
Vim is unable to map non-ascii keys (æ, ø, å) in my utf-8-encoded .vimrc.
I am using Scandinavian letters (æ, ø and å) in mappings and as leader. When
changing 'encoding' from latin1 to utf-8 and writing/sourcing my .vimrc (as
utf-8), the mappings break. I asked on StackOverflow for help (link to question
below), and the answer was that this seems to be platform-specific. Therefore,
I assume this is a bug.
If this indeed is a bug, I'll be happy to assist in any way I can, whether it
is providing more information, testing or anything else.
## Further details:
StackOverflow question with a few more details:
http://stackoverflow.com/questions/18421131/how-can-i-bind-non-ascii-keys-with-a-utf-8-encoded-vimrc
### Specific steps to reproduce:
Using this .vimrc:
https://github.com/lstor/vimfiles-lstor/blob/7bbe1fe46a4ee2e8b5b671b50b54cbc695149250/vimrc#L98,L99
0. The above .vimrc works. Pressing ø then h will call :nohls. Pressing :å will
generate :[ on the command line.
1. Add 'set encoding=utf-8' between line 98 and line 99. (Although the line
numbers shouldn't matter.)
2. :write the .vimrc, converting 'ø' from latin1 to utf-8.
3. :source .vimrc
4. Pressing ø rings the error bell.
### Version and setup info
I am using gVim 7.4 32-bit on Win7 64-bit. I have not been able to test any
other platforms.
There are two possible problems here:
1) Does Vim understand how the text in your vimrc is coded? See :help
:scriptencoding
If all the text in your vimrc uses only Unicode codepoints no higher
than U+00FF, you could add near the top
scriptencoding latin1
In that case, the æ and ø in the mappings' {lhs} would be coded in
Latin1 and (if you set 'encoding' to UTF-8 before declaring them) Vim
would know to convert them to UTF-8.
Conversely, if there are higher Unicode codepoints in your vimrc, you
would use
scriptencoding utf-8
instead, and Vim would know that it mustn't try to interpret the codes
in the script as Latin1 when interpreting it.
2) Does Vim understand how the keyboard interface represents the
keypresses? See http://vim.wikia.com/Working_with_Unicode
At startup, Vim stores your locale's charset as the starting value of
'encoding' (meaning how the text is stored in memory) and set
'termencoding' to the empty string (meaning: data from the keyboard is
to be interpreted according to 'encoding'). When you change 'encoding',
the OS doesn't know that, and the keyboard will continue to send the
same codes as before, so there is a risk that Vim might try to interpret
according to UTF-8 some codes sent in Latin1. Anything above 0x7F in
Latin1 gives invalid UTF-8, except in extremely rare cases.
To avoid such misunderstandings, I recommend saving the old value of
'encoding' (the charset in your system locale) in 'termencoding' before
you set 'encoding' to something else: see the example snippet of code in
the wiki article.
Best regards,
Tony.
--
Little Known Facts, #23:
Did you know... that if you dial 911 in Los Angeles you get
the BMW repair garage?
--
--
You received this message from the "vim_dev" 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
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.