top of page

Fix E216: No such group or event: filetypedetect BufReadPost msg in <SNR>14_XxdBack

Updated: May 2, 2023

This post shows two ways to stop an error that pops up in gVim > Tools > Convert Back:

Error detected while processing functions <SNR>14_XxdBack:

line 9:

E216: No such group or event: filetypedetect BufReadPost

This message goes away when you press Enter.

Method 1


:filetype on

Note, this action causes:

Detail: The ":filetype on" command will load one of these files:
		Amiga	    $VIMRUNTIME/filetype.vim
		Mac	    $VIMRUNTIME:filetype.vim
		MS-DOS	    $VIMRUNTIME\filetype.vim
		RiscOS	    Vim:Filetype
		Unix	    $VIMRUNTIME/filetype.vim
		VMS	    $VIMRUNTIME/filetype.vim
	This file is a Vim script that defines autocommands for the
	BufNewFile and BufRead events.  If the file type is not found by the
	name, the file $VIMRUNTIME/scripts.vim is used to detect it from the
	contents of the file.
	When the GUI is running or will start soon, the menu.vim script is
	also sourced.  See |'go-M'| about avoiding that.

Method 2

Change menu.vim so that filetypedetect is only called if did_load_filetypes exists (thank you to Bram for suggesting a better conditional).

--- menu.vim.orig       2022-06-28 07:08:36.000000000 -0600
+++ menu.vim    2023-05-02 20:20:00.052527000 -0600
@@ -599,8 +599,10 @@
     exe ':%!' .. g:xxdprogram .. ' -r'
-  set ft=
-  doautocmd filetypedetect BufReadPost
+  if exists('#filetypedetect') && exists('#BufReadPost')
+    set ft=
+    doautocmd filetypedetect BufReadPost
+  endif
   &mod = mod

Method 2 demonstrates why Method 1 works, namely that since filetypedetect is defined in filetype.vim and since typing :filetype on loads filetype.vim, filetypedetect is loaded when the Convert Back menu item runs which allows the menu item to run without raising the message.


Vim logo

Vim (text editor). (2023, April 20). In Wikipedia.


bottom of page