2008/10/6 Tony Mechelynck <[EMAIL PROTECTED]>:
>
> On 06/10/08 09:16, Yongwei Wu wrote:
>> 2008/10/6 Noah Spurrier<[EMAIL PROTECTED]>:
>>> I put this as the last line in a Python program I'm working on:
>>> # vim:set sr et ts=4 sw=4 ft=python fenc=utf-8:
>>
>> fenc cannot be normally used for determining the encoding of the file,
>> since it is set *after* the file is loaded. Try opening a file, and
>> then setting fenc, and you will understand it.
>>
>> This said, I also think setting fenc in the file is something wanted.
>> I made this work in the plug-in fencview. One still needs to remember
>> that this kind of files may cause trouble to others. The key function
>> for this functionality is shown below:
>>
>> function! s:CheckModelineFileEncoding()
>> if&modified&& &fileencoding!=''
>> if s:disable_autodetection<2
>> let Syn=&syntax
>> exec 'edit! ++enc='.&fileencoding
>> if Syn!=''
>> let&syntax=Syn
>> endif
>> elseif exists('s:fencview_manual_enc')
>> let&fileencoding=s:fencview_manual_enc
>> set nomodified
>> endif
>> endif
>> endfunction
>>
>> exec 'au BufWinEnter ' . g:fencview_auto_patterns .
>> \' call s:CheckModelineFileEncoding()'
>>
>> Best regards,
>>
>> Yongwei
>>
>
> Note that s: variables cannot be set manually to other values without
> editing the script. I believe the g: scope would be more useful,
> allowing the above snippet to be distributed as part of a separate
> global plugin whose config settings would be set in the vimrc and, if
> desired, changed manually afterwards.
This is just a code snippet. The plug-in will set this script variable
when needed. It is not supposed to be changed by the user, and the
script will change it.
Best regards,
Yongwei
--
Wu Yongwei
URL: http://wyw.dcweb.cn/
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---