Ben Fritz schrieb:
> I posted this originally on vim_use but only got one response, from
> someone who thinks it's a bug. The original thread is here:
>
> http://groups.google.com/group/vim_use/browse_thread/thread/d93a0878b9a5bb91/8619edd9992fdd20
>
> Basically, I have two tabs open, each with a single buffer loaded, and
> a BufRead autocmd that will fire when the file in one of the tabs is
> (re)loaded. This BufRead autocmd sets the "wrap" option locally. When
> the autocmd fires, the buffer in the currently active tab gets the
> option, regardless of whether this is the buffer being reloaded.
>
> Test case for reproduction is as follows:
> vim -u NONE -N -i NONE
>
> :autocmd BufRead *.txt setlocal wrap
> :view test.txt
> :tabe test.c
> :setlocal nowrap
>
> Now modify test.txt outside of Vim and give focus back to Vim to
> trigger a reload of test.txt.
>
> Vim is still in the test.c tab. When the BufRead autocmd fires, 'wrap'
> is set for test.c instead of test.txt.
>
> Is this a bug? If not, please explain :-)
>
> I'm running gvim 7.2.160 on MS Windows (the "Cream" build).
The 'wrap' option is local to the window. (Obviously) Vim does not
switch to the buffer's window when reloading a file -> the option can be
set in the wrong window.
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
--
Andy
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---