Vim: exists('#TerminalOpen') returns 0 in Vim 8.1

Created on 1 Jun 2018  路  3Comments  路  Source: vim/vim

                            *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.

Most helpful comment

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.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mgedmin picture mgedmin  路  5Comments

j0ker70 picture j0ker70  路  3Comments

SRGOM picture SRGOM  路  4Comments

GoogleCodeExporter picture GoogleCodeExporter  路  3Comments

lacygoill picture lacygoill  路  3Comments