Ben Fritz schrieb:
> On May 12, 6:55 am, Andy Wokula <[email protected]> wrote:
>
>> I found that  :setf {ft-name}  does nothing when auto-reloading a file
>> (intentionally I guess), so
>>
>>    :au FileType text setl wrap
>>
>> works better for me.  And it somehow looks better anyway ...
>>
>> Of course you need to define the filetype "text".
>>
>> In other words ...
>>
>> Setting a window-local option from a buffer-event like BufRead does not
>> look right ... and Vim indeed has some separation:
>>
>>     BufRead event -> FileType event

>> BufRead: buffer must match
>> FileType: buffer + buffer's window must be current, else FileType event
>>           is not fired

Ok.  It only works this way by accident:

I used  :setf text  like in the filetype.vim file(s), instead of
:setl ft=text, and :setf is short for

    if !did_filetype()
        setlocal filetype={filetype}
    endif

did_filetype() "returns non-zero when autocommands are being executed
and the FileType event has been triggered at least once." (since
creation of the buffer or so ...).

> Your method does not seem to work for me. My simple test case may be
> too simple. From the vim_use email:
>
>> My actual situation is more complicated. The :setlocal wrap is not in
>> an autocmd, but rather in $HOME/vimfiles/ftplugin/txt.vim, detected by
>> file extension in $HOME/vimfiles/ftdetect/txt.vim with the following
>> command:
>>
>> au BufNewFile,BufRead *.t{e,}xt,*.log,*.csv,*.err set filetype=txt

Use :setf, see above.

> This is the case in which I originally observed the behavior.
>
> When I remove the setlocal wrap from the ftplugin file, and add an
> FileType autocmd to do the same, I get the same results.

no surprise: the trigger is the same.

> It was always my understanding that the ftplugin files only got
> sourced during application of a filetype, which also fires off the
> FileType event. Am I missing something? Or perhaps I'm setting the
> filetype in a strange manner?

-- 
Andy

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

Raspunde prin e-mail lui