On Sun, Dec 29, 2013 at 4:54 AM, Ben Fritz <[email protected]> wrote:
> 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.
>

Ah, ok, thanks. I already thought it was something like that. I
thought I tried the other way around, but I missed that somehow.

I agree that not every plugin should just change the encoding like
that, however, the plugin advocates itself as a set of "sane defaults"
for VIM. Setting encoding to utf-8, instead of latin1, actually makes
more sense to me ;) I'll make sure that encoding=utf-8 will be the
very first thing that happens.

-- 
-- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to