I have a nifty autocommand in my vimrc
that automatically maximizes any :help
window:
augroup LargeHelpWindow
autocmd!
autocmd BufWinEnter * if &l:buftype ==# 'help' | wincmd _ | endif
augroup END
This is really useful to optimize screen usage when using :help
and it is based on buffer type. I would like to achieve the same for :Man
so that I can comfortably view and navigate man
documentation in Vim. However, since :Man
buffers have buftype
set to nofile
and filetype
set to man
, I have to configure the resizing based on filetype. I have tried the following:
autocmd Filetype man wincmd -
autocmd BufWinEnter * if &l:filetype ==# 'man' | wincmd _ | endif
autocmd WinEnter * if &l:filetype ==# 'man' | wincmd _ | endif
but this has not worked, i.e. :Man
windows stay small and they need to be resized manually. I believe the reason for the failure of the autocommands above is the relative order of BufWinEnter
and WinEnter
vs Filetype
. Unfortunately, the exact relative order is not well documented.
Is there a way to achieve automatic resizing of windows based on filetype?