I have a nifty autocommand in my vimrc that automatically maximizes any :help window:

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

2 Answers 2


autocmd FileType man wincmd _ should work okay. Most probably you have a typo (e.g. in your post it's "dash" instead of "underscore").

Concerning auto-events, not all of them are bound to follow specific sequence. For example, FileType is triggered right after 'filetype' option was set. For whatever reason.

  • I can confirm that the problem was indeed a dash - instead of an underscore _. Thanks!
    – mgarort
    Commented Feb 26, 2021 at 12:30

Caveat: I don't have the :Man command which you have presumably defined yourself, but this should work:

autocmd BufEnter * if &filetype ==# "man" | wincmd _ | endif
  • Thanks! This works too. I have decided to accept the other answer because it was a bit more informative as to why my solution didn't work, but this also fixes the problem. Regarding :Man, in order to use it you have to source the appropriate plugin first: runtime ftplugin/man.vim,
    – mgarort
    Commented Feb 26, 2021 at 12:31
  • No worries, glad it worked out and thanks for the the information on :Man, I was not aware of that. Commented Feb 26, 2021 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.