There are at least three ways to tell if a particular autocmd is supported:
Use exists('##CmdlineEnter')
. This should be exactly what you need.
Check for the patch it was introduced in. For example, CmdlineEnter
was added in patch 8.0.1206. I determined this by looking at recent vim commits and git blame on the help files. Thus you can use has('patch-8.0.1206')
. Although Neovim does not follow vim development exactly, when features are added from "upstream," the vim patch numbers are included too.
Use a try|catch|endtry
block around autocmd
. E.g.,
try
silent autocmd CmdlineEnter
catch /^Vim\%((\a\+)\)\=:E216/
" autocmd is not supported
endtry
When installing an autocmd handler you could simply use silent! autocmd CmdlineEnter * ...
to suppress all errors, if your code doesn't actually need to know whether the command is supported.
Alternatively, you can check if an autocmd is subscribed to using exists('#CmdlineEnter')
. This will return 0 if the autocmd exists but has no listeners. Sometimes this is all the info you need.