1

When I display a vim helpfile by running e.g. :h au, the help is displayed in a horizontal split window:

vim help

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?

jottr
  • 3,256
  • 3
  • 29
  • 35

4 Answers4

3

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
Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • Thank you @Ingo, your modification solved my problem. Would you mind explaining the `&l:` and `==#` constructs? I am unsure what `&l` does and why you used the `#` character in the comparison. – jottr Jun 30 '14 at 09:44
  • Great! The `l:` prefix selects the `:setlocal` value; you could also leave it out. `==#` is a case-sensitive comparison. As you see, I try to be very explicit in Vimscript. – Ingo Karkat Jun 30 '14 at 11:34
1

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
Don Hatch
  • 5,041
  • 3
  • 31
  • 48
  • You could explain what makes your solution preferable over the one accepted. Also, the question asked for help writing an augroup, and not for an ex-command, so you could explain why your solution is preferable compared to the solutions already proposed. – jottr Jul 11 '15 at 10:38
  • @jottr, you're the one who asked the question-- my impression is that my answer achieves your goal ("... the help buffer to open in a maximized window automatically") more simply and directly than the approach you tried. Is that not the case? You say you defined your augroup in your .vimrc-- so I think you could put the "set helpheight=9999" there instead, right? Let me know if I'm really missing something, but if you're just asking me to spell out something that's already clear, I will decline. – Don Hatch Jul 13 '15 at 21:55
  • All right, spelled it out. Still not sure whether I'm missing something. I hope it solves your problem. – Don Hatch Jul 13 '15 at 22:10
0

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:

  1. Try changing wincmd _ to set winheight=9999 in your augroup script.
  2. How about opening the help in a new tab with wincmd T instead?
Evan Sebastian
  • 1,714
  • 14
  • 20
-1
|CTRL-W_o|      CTRL-W o           close all but current window (like |:only|)
louie_45
  • 9
  • 3
  • 1
    Can you explain more your answer please ? – Zulu Jul 15 '15 at 01:14
  • when you have splitted the window, clicking the 'CTRL-W o' would make current active window only on the vim (others are closed which you could use ':ls' to see them). – louie_45 Jul 16 '15 at 05:28