Friday, January 11, 2013

Re: Using autocommand to change scrolloff but it is changed in all buffers

Am 11.01.2013 19:54, schrieb skeept:
> Hi,
>
> I have the following autocommand
>
> "set readonly files to autoread
> autocmd BufRead,BufNewFile * if &readonly == 1 | setlocal autoread so=0
> \ sbo+=ver,hor | endif
>
>
> I usually set so=2 in my vimrc. After I use vim help the value of so
> is changed in all buffers to be 0.
> I am sure that this autocommand is causing this because if I change
> so=0 to so=3 then all buffers will have so=3 after I call help.
>
> Am I doing this correctly?

'scrolloff' is a global option, :setlocal can be used to change a global
value (and does not complain):
:h 'so

There are
* global options (one value is shared by all buffers, example:
'scrolloff'),
* buffer-local options (each buffer has its own copy, example:
'readonly') and
* global-local options (buffers *can* have a local copy; if not, the
global value is used; example: 'autoread').

:h local-options
:h global-local

You could try to change the global option 'so' on each BufEnter event.

--
Andy

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

No comments: