5

From the Vim event documentation:

Vim recognizes the following events. Vim ignores the case of event names (e.g., you can use "BUFread" or "bufread" instead of "BufRead").

So in my custom_filetype.vim, I use au filetype to run a command when FileType events occur. It worked fine for me until I updated my vim to a newer patch level:

$ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 19 2015 14:09:11)
Included patches: 1-922
Compiled by cuonglm@debian

Now vim will raise an error with au filetype:

$ vim
line   93:
E216: No such event: jinja :call Jinja_config()
Press ENTER or type command to continue

Changing any letter in filetype to uppercase, like Filetype, fileType or even fIletype worked.

I went through git log but can not find any issues.

Is this change intentional or do I have any mis-configuration?

  • 2
    can you git-bisect and find the offending patch? – Christian Brabandt Nov 20 '15 at 9:46
  • @ChristianBrabandt: I try git bisect from patch 900 but the problem still occur. I don't remember the exactly patch before I updated to patch 922. The culprit can also be my plugins updated. I am trying to find what's the real culprit. Do you have the same issue with latest patch? I updated to 930 and the problem still occur. – cuonglm Nov 21 '15 at 3:35
  • @ChristianBrabandt: It seem that problem came from one of my plugins. If I clean up all the plugins, then left only au filetype * set bg=dark in .vimrc, it worked fine. Any suggestion to trace this problem? – cuonglm Nov 27 '15 at 4:11
  • Depending on the number of plugins, this can be a tedious task. You would have to disable the plugins one by one and check. I don't know a better way. – Christian Brabandt Nov 27 '15 at 8:58
  • 1
    sorry, i can't explain this issue. Perhaps Vim should warn in a case like yours. – Christian Brabandt Dec 4 '15 at 7:26
7
+100

I looked into the source and I think I found the problem. If you look in the help (:h :au) you will see this:

:au[tocmd] [group] {event} {pat} [nested] {cmd}
        Add {cmd} to the list of commands that Vim will
        execute automatically on {event} for a file matching
        {pat} autocmd-patterns.
        Vim always adds the {cmd} after existing autocommands,
        so that the autocommands execute in the order in which
        they were given.  See autocmd-nested for [nested].

The problem is the [group] part. Your autocommand from your config was this: au filetype jinja :call Jinja_config()

This means your autocmd filetype jinja will be parsed as an autocommand, belonging to the filetype group, using the jinja event, which does not exist. Therefore you get that error E216: No such event: jinja.

Even when using the * as pattern, this would not work as expected, because the * would be parsed as meaning all available events and the pattern would then be parsed as the first part of your command, which is obviously wrong.

I would suggest opening an issue at the plugins page, that defines that augroup filetype as this will cause trouble.

1

After checking all the plugins, I found the issue due to the vim-systemtap plugin, which define an augroup named filetype:

augroup filetype
  au BufNewFile,BufRead *.stp   set filetype=stp
augroup end

It seems that group name would override the event name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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