I'm trying to learn more about augroups, which have always confused me. The Section 43.2 documentation (:help 43.2) makes it clear that the filetypedetect group should be used to group autocmds which set filetypes, as grouping them in this way allows the autocmds to be turned on and off collectively.

However, I am not clear about one minor detail: should autocmd or autocmd! be used in the filetypedetect augroup? I understand how they differ, but it seems the documentation offers contradictory recommendations. Section 43.2 (:help 43.2) shows a filetypedetect augroup which uses autocmd while part C of the new-filetype documentation (:help new-filetype) shows a filetypedetect augroup which uses autocmd!.

Should autocmd or autocmd! be used in filetypedetect augroups?

  • IIRC autocommands put in ftdetect scripts are automatically put in a group
    – D. Ben Knoble
    Jun 23, 2021 at 12:17
  • That's true but filetypedetect groups are unrelated to the ftdetect directories. They are part of an alternative approach to detection. (There are a total of four approaches.)
    – B Layer
    Jun 23, 2021 at 23:58
  • You made a damn fine point @John (though I should have thought of it myself) and my answer would have to change to doing au! everywhere but filetypedetect in which case you'd use au! Events ...etc. I'd rather nuke an answer than give a wishy washy one. :)
    – B Layer
    Jun 24, 2021 at 20:31


Your Answer

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

Browse other questions tagged or ask your own question.