How to disable Vim bells sounds?
Asked Answered
R

6

87

I am trying to disable the error bells on vim, both visual and audio. However I cannot get them to stay off.

I have the following in my vimrc:

" Disable annoying beeping
set noerrorbells
set vb t_vb=

That doesn't work, I figured some plugin or another setting was resetting it so I added it again to the end of my vimrc, still no luck.

The only way I can get it to turn off is if I manually call set vb t_vb= after everything has loaded. I guess I could emulate this by adding a script to the plugin/after folder but I am trying to avoid that as it means it's another thing I have to set up whenever I switch to another machine.

You can see my full vimrc here: https://github.com/lerp/dotfiles/blob/master/vimrc

Ricardaricardama answered 3/9, 2013 at 9:59 Comment(2)
This sound is so annoying. Why is it on by default?? Is there anyone out there who might change that???Lobbyist
@Soren - The sound depends on your terminal. Back in the day, the terminal bell was pretty innocuous on most terminals. Remember, back when vi started, we used hardware terminals like VT100 and ADM3. (And now you can say "OK Boomer.")Southward
G
39

Assuming you have that problem in GVim, adding the following line

autocmd GUIEnter * set vb t_vb=

in your if has("gui_running") conditional block should help.

From :help 'visualbell':

Note: When the GUI starts, 't_vb' is reset to its default value.
You might want to set it again in your gvimrc.
Goddamn answered 3/9, 2013 at 10:14 Comment(2)
Ahh, I must have skipped that line whilst reading the help file, I don't understand why it needs to be reset, it's a bit obnoxious. Thanks for the autocmd though.Ricardaricardama
Here is the link to the vim docs where it is mentionedJueta
F
175

Try to use the following line in your .vimrc, .gvimrc files:

set belloff=all
Feldspar answered 7/1, 2017 at 17:1 Comment(8)
Thanks - other answers work for disabling visual bell, but this is the setting that disables audio bell for me.Pulchritude
Works on vim-gtk3 8.0.Valenciavalenciennes
This worked on Ubuntu 16LTS after updating the default version of vim with sudo apt install vim which installed version 8Outcome
i still get beeps when pressing down arrow on last line in insert modeEntrain
This one produces an error using PowerShell to ssh into RedHat, entered it into ~/.vimrc, and then running vi. So, not viable in vi on RedHat?Lazurite
On my (cygwin) installation the file was ~/.vim/vimrc not ~/.vimrc. The RC file locations can be discovered by running vi --version.Verrucose
Like a hammer to the thumb, that bell is a direct hit my cerebral cortex. owKlein
Can be shortened to set bo=allTwilatwilight
G
39

Assuming you have that problem in GVim, adding the following line

autocmd GUIEnter * set vb t_vb=

in your if has("gui_running") conditional block should help.

From :help 'visualbell':

Note: When the GUI starts, 't_vb' is reset to its default value.
You might want to set it again in your gvimrc.
Goddamn answered 3/9, 2013 at 10:14 Comment(2)
Ahh, I must have skipped that line whilst reading the help file, I don't understand why it needs to be reset, it's a bit obnoxious. Thanks for the autocmd though.Ricardaricardama
Here is the link to the vim docs where it is mentionedJueta
L
15

For me with gVim it works if I put

set noerrorbells
set vb t_vb=

in ~/.gvimrc, not ~/.vimrc.

Laborious answered 29/3, 2016 at 23:42 Comment(0)
P
8

To disable visual bell in Visual Studio 2019 with VsVim extension:

VsVim detects the presence of _vimrc, so add the following to it:

C:\Users\YourName\_vimrc

set vb t_vb=

Setting other options like errorbells or beloff had no effect in VsVim.

Punchinello answered 18/10, 2020 at 10:5 Comment(2)
I had installed vim extension in pycharm and this solution worked!Broken
Nothing to do with vsvim or Visual Studio, but this option is the only one given that worked for me -- using PowerShell to ssh into RedHat, and then running vi therein.Lazurite
S
5

After trying all the options mentioned (that haven't worked for me), I figured out the following solution and that worked for me (Windows). The beep sound is related to the git bash terminal settings.

Follow these steps:

  1. Right-click on the terminal/git bash or whatever you are using.
  2. Click on options.
  3. Select Terminal.
  4. From Bell drop-down select "no beep".

Shatzer answered 5/5, 2020 at 6:14 Comment(1)
Also, you can change the beep into an innocuous sound.Southward
M
3

I tried several solutions and different configurations but none worked. GVim resets the visual bell upon starting. The only way it works for me is this snippet at the end of your .vimrc (or _vimrc if you are on Windows):

set visualbell t_vb=
if has("autocmd") && has("gui")
    au GUIEnter * set t_vb=
endif
Maclay answered 10/10, 2015 at 21:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.