*TerminalOpen*
TerminalOpen Just after a terminal buffer was created, with
`:terminal` or |term_start()|. This event is
triggered even if the buffer is created
without a window, with the ++hidden option.
reproduce:
:echo exists('#TerminalOpen')
output is 0. But it is supposed to return 1.
I want to turn off line number for a terminal buffer and TerminalOpen event is required in my autocmd. But to keep compatible to old vims, I need detect if it is supported.
This returns 1.
au TerminalOpen * echom 'open!'
echo exists('#TerminalOpen')
from :help exists()
event autocommand defined for this event
exists('#TerminalOpen') checks if any autocommand is defined for TerminalOpen (not TerminalOpen is usable or not).
If you want to check TerminalOpen is usable, just check by v:version >=# 801 or has("patch-8.0.1596").
It seems you missed the other part of the help that mentions using ##event to check if the event is supported.
:echo exists('##TerminalOpen') should do what's requested.
@jamessan oh... thanks! I didn't know that.
Most helpful comment
It seems you missed the other part of the help that mentions using
##eventto check if the event is supported.:echo exists('##TerminalOpen')should do what's requested.