bell(), looking for builtin function to ring the bell

12 views
Skip to first unread message

Ernie Rael

unread,
Sep 13, 2023, 12:32:30 PM9/13/23
to vim...@googlegroups.com

Greetings,

In a plugin I'm working on, when certain simple errors occur, I want to ring the bell, some kind of alert. A popup, use in some place in the plugin, is more than is needed.

The closest thing I can find is

call sound_playevent('bell')

which isn't cross platform.

What have I missed?

-ernie

Yegappan Lakshmanan

unread,
Sep 13, 2023, 12:42:59 PM9/13/23
to vim...@googlegroups.com
Hi,
There is no builtin function to just ring the bell. You can try using
the following:

set errorbells
echoerr ''
set noerrorbells

Regards,
Yegappan

Gary Johnson

unread,
Sep 13, 2023, 12:49:02 PM9/13/23
to vim...@googlegroups.com
I use

normal \<Esc>

but I don't know how cross-platform it is. It's documented at

:help :echoerr

You don't have to use :exe. I surround it with a test for
'errorbells', e.g.,

if &errorbells
normal \<Esc> " Generate a bell
endif
echohl ErrorMsg
echomsg "Oops!"
echohl None

Regards,
Gary

Ernie Rael

unread,
Sep 13, 2023, 1:31:24 PM9/13/23
to vim...@googlegroups.com
On 23/09/13 10:48 AM, Gary Johnson wrote:
> I use
>
> normal \<Esc>
>
> but I don't know how cross-platform it is. It's documented at
>
> :help :echoerr
>
> You don't have to use :exe. I surround it with a test for
> 'errorbells', e.g.,
>
> if &errorbells
> normal \<Esc> " Generate a bell
> endif
> echohl ErrorMsg
> echomsg "Oops!"
> echohl None

Thanks.

-ernie

>
> Regards,
> Gary
>

Reply all
Reply to author
Forward
0 new messages