Reputation: 3293
When I display a vim helpfile by running e.g. :h au
, the help is displayed in a horizontal split window:
Currently I always run Ctrl+w _
but I would prefer the help buffer to open in a maximized window automatically.
I've tried to create an autocmd to solve the issue:
"Automatically maximize help buffers
augroup filetype_help
autocmd!
autocmd BufWinEnter,FileType help wincmd _
augroup END
which only works sporadically.
EDIT:
I have done some further debugging.
Opening a certain help page the first time, e.g. :h au
displays it maxmimized when having above augroup in my .vimrc
.
Closing the helpfiles window via :q
and then reopening the same helpfile a second time causes the help file to be displayed in a split as in the screenshot above.
Closing the helpfiles buffer window via :bd
and then reopening it, causes it to being displayed maximized as desired.
How can I rewrite my augroup so that it also maximizes an already opened help buffer?
Upvotes: 1
Views: 1184
Reputation: 5509
I think you can achieve your goal of getting your help buffers to be maximized more simply by putting the following in your .vimrc (or wherever), instead of the augroup/autocmd:
:set helpheight=9999
Upvotes: 1
Reputation: 172688
The BufWinEnter
event matches the help filename, so the help
pattern (which is fine for a FileType
match) won't work. The 'filetype'
option is only set once for a buffer, so when it is reused (after :q
, but not after :bd
), your maximization fails, in the way you've reported.
Instead, have the :autocmd
match all buffers, and check for the 'buftype'
:
augroup filetype_help
autocmd!
autocmd BufWinEnter * if &l:buftype ==# 'help' | wincmd _ | endif
augroup END
Upvotes: 3
Reputation: 1744
I assume you'd like the help window to be horizontally maximized.
Sorry, I can't reproduce your bug (tried on MacVim 7.4-258 and vim 7.4-258), but here are some suggestions:
wincmd _
to set winheight=9999
in your augroup script.wincmd T
instead?Upvotes: 0