Friday, January 5, 2018

Re: buttype == quickfix plus WinEnter

On Thursday, January 4, 2018 at 5:00:31 AM UTC-6, Axel Bender wrote:
> I would like to set the (unfortunately global) scrolloff option dynamically.
> To accomplish that, I use the following construct (simplified):
>
> autocmd BufEnter * call SetScrollOff()
>
> function SetScrollOff()
> let &scrolloff = &buftype == "quickfix" ? 3 : 5
> endfunc
>
> This approach works fine for non-quickfix windows.
> However, when entering the quickfix window *for the first time* with e.g. :qf, scrolloff is not getting set.
> When entering the quickfix window the next time, the approach works as intended.
>
> Do I use the wrong
> a) event,
> b) comparison?

I have a similar set of autocmds. I used the &filetype rather than &buftype (maybe the autocmd predates the quickfix buftype?) but the intent is the same.

I also used BufEnter for my main autocmd.

However, I have a comment in my vimrc that "File type will not be set on the first BufEnter" followed by a second "FileType qf" autocmd to also set the scrolloff appropriately. Possibly the buftype acts the same way and you'll need to use the same method.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment