I have a file for which the filetype is not correctly set.

The filetype is set by an autocmd but I would like to identify which one.

How can I know which autocmd have been triggered when I load my buffer and where these autocmd have been defined?

Or alternatively can I see the list of all autocmd that are currently defined:

  • Their orders (priority)
  • Their definition (script, line number)

1 Answer 1


I used:

:verbose autocmd

Or with the scriptease plugin:

:Verbose autocmd

I can then search the result for my file pattern (e.g. *.cfg) or the filetype it has been assigned too (e.g. cfg)

I can then filter the output with the following two commands:

:g!/\v(^\s+\*\.cfg\_.{-}Last set.*$|^\S.*$)/d

To get only the lines that are relevant for the *.cfg file pattern.

  • 1
    Also :filter, but not all commands are supported IIUC
    – D. Ben Knoble
    Aug 28, 2022 at 18:21
  • Thanks @D.BenKnoble. Could you develop a bit about :filter? Do you propose that I use filter to focus the result of verbose autocmd to focus on the lines that are relevant to the question. How do you propose to use :filter Aug 29, 2022 at 3:23
  • 1
    One would hope that :filter /pat/ autocmd would work, but alas it does not
    – D. Ben Knoble
    Aug 30, 2022 at 14:22

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.