Lerp
Lerp

Reputation: 3127

How to disable Vim bells sounds?

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

Upvotes: 91

Views: 66680

Answers (6)

adelriosantiago
adelriosantiago

Reputation: 8124

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

Upvotes: 3

rbento
rbento

Reputation: 11608

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.

Upvotes: 9

prakhar srivastava
prakhar srivastava

Reputation: 51

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

Upvotes: 5

Mark
Mark

Reputation: 6394

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

set belloff=all

Upvotes: 181

pozitron57
pozitron57

Reputation: 165

For me with gVim it works if I put

set noerrorbells
set vb t_vb=

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

Upvotes: 15

romainl
romainl

Reputation: 196526

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.

Upvotes: 39

Related Questions