Saturday, December 28, 2013

Re: encoding=utf-8 breaks my alt key on Windows

On Saturday, December 28, 2013 1:43:13 PM UTC-6, Thijs Brobbel wrote:
> Hi,
>
>
>
> I just installed vim-sensible, a plugin that sets a couple sane
>
> defaults, and I found out that it broke my mappings which uses the alt
>
> key. After a little bit of debugging I found out that setting
>
> encoding=utf-8 caused this.
>
>
>
> Does anyone know why this happens? And more importantly, how I can fix
>
> this, without disabling the affecting line.
>
>
>
> Steps to reproduce:
>
> map <a-a> :w<cr>
>
> set encoding=utf-8
>
>

Setting the 'encoding' option affects how Vim interprets bytes stored internally, including mappings.

If you set the encoding and then create a mapping, all will be well. Vim creates the mapping using the encoding, then reads it back in the same encoding.

But if you create a mapping and then set the encoding, then the mapping is *stored* in your default encoding (probably ISO-8859-1, a.k.a. Latin1) but then reads it back as if it were utf-8. This results in an incorrectly interpreted mapping at best.

The solution: make sure to set encoding at the very top of your .vimrc. There should be no mappings or abbreviations or register settings or string options or anything else that could change based on encoding before that line in your .vimrc.

If it's in the plugin, not your .vimrc, then that plugin is just asking for trouble and should not have done this.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment