Friday, January 11, 2013

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

Hi,

--------message d'origine --------
De: skeept <skeept@gmail.com>
A: vim_use@googlegroups.com
Sujet: Using autocommand to change scrolloff but it is changed in allbuffers
Date: Fri, 11 Jan 2013 10:54:21 -0800 (PST)

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

Maybe you should use several autocommands, depending of the variable type (global or local),
the events, the filetype and so on... In the case you describe, you want to have 'so' set to
0 when you read the help file (when the help buffer is the active one) and come back to so=2
when you leave the help, isn't it ?

In my vimrc, I use this:

set scrolloff=5
[...]
autocmd BufEnter,TabEnter,WinEnter * if &filetype=="help" || &buftype=="help" | set scrolloff=999 | else | set scrolloff=5 | endif

This works as expected. Cheers
quidame

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