1

Using Vim 7.4. My ~/.vimrc file consists only of the following:

set nocompatible
filetype off

If I run vim with verbose logging level 2 by using the following command:

vim -V2./file.log .vimrc

...it gives the following error in file.log:

line 5: sourcing "/usr/share/vim/vim74/ftoff.vim"
Error detected while processing /usr/share/vim/vim74/ftoff.vim:
line   11:
E216: No such group or event: filetypedetect *
finished sourcing /usr/share/vim/vim74/ftoff.vim

The ftoff.vim file is the following (sans comments):

if exists("did_load_filetypes")
  unlet did_load_filetypes
endif

" Remove all autocommands in the filetypedetect group
silent! au! filetypedetect *

So it appears there is an error in ftoff.vim? If not, is there a better way to set filetype off than the filetype off command?

1

The fact that you are getting this message on your verbose log file is expected.

The Vim source code has an explicit comment about that:

/*
 * When using ":silent! cmd" ignore error messages.
 * But do write it to the redirection file.
 */

I linked to the code in Vim 7.4, but Vim 8.2 still has the same exact snippet and exhibits the same behavior.

I assume this behavior exists because you'd enable verbosity and a redirect file when you're debugging an issue. In those circumstances, logging errors that would otherwise be silented can be quite helpful. Also, there's little harm in printing those messages, since they're not interrupting the user, but simply going to the verbose redirect file.

So it appears there is an error in ftoff.vim? If not, is there a better way to set filetype off than the filetype off command?

I wouldn't call it a bug, since you're asking for debugging information and you're simply getting what you asked for. You're likely to get that from many more Vimscript snippets that are using :silent and will have their silented errors logged if you run with verbose logging.

Furthermore, the implementation in ftoff.vim will not print any errors (even to the redirected verbose file) if the filetypedetect augroup was ever created (in other words, if filetype was ever enabled.) Note that it doesn't really remove the augroup, it simply clears it, so disabling filetype repeatedly after ever enabling it will not really print errors (to the redirect file.)

You could argue it would have been best to check whether the augroup actually exists before trying to clear it, but arguably using :silent! is a much shorter way to accomplish that and it doesn't really present significant drawbacks (perhaps having the error hit the verbose redirect log being a minor annoyance, at most.)

| improve this answer | |
0

is there a better way to set filetype off than the filetype off command?

filetype is off by default in Vim (but note: no vimrc means sourcing defaults.vim which does enable filetype). Therefore, you should just remove the 2nd line.

So it appears there is an error in ftoff.vim?

silent! stands there to shut up any error if filetypedetect does not exist (yet). So it should be okay to do filetype off even if filetype was never ever "ON" before. You see something only because of verbose option, which normally should be off.

| improve this answer | |

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.