Technology
 

Disable beeping

From Vim Tips Wiki

(Redirected from VimTip418)

Tip 418 Previous Next created February 3, 2003 · complexity basic · author Dave · version 6.0


How do you stop gvim from beeping on error?

 :set visualbell

If you also want to get rid of the screen flash caused by the 'visualbell' option, paste the following function into your vimrc:

set noerrorbells
set visualbell
set t_vb=

[edit] Comments

 TO DO 

  • Merge or delete the rest of the comments below
  • Add :help references
  • Clean up tip description?
function! Errorbells_off(...)
  " control Vim's audio and visual warnings
  " * Arguments:
  " "beep": turn off just beeping
  " "flash": turn off just flashing
  " (empty): both off
  " * Must be initialized after the GUI starts!
  " off
  if a:0 == 0
    let myeb = ""
  else
    let myeb = a:1
  endif
  if myeb ==? "flash"
    " audibly beep on error messages
    set errorbells
    " Screen flash on error (See also 't_vb')
    set novisualbell
    set t_vb=
  elseif myeb ==? "beep"
    " audibly beep on error messages
    set noerrorbells
    " Screen flash on error (See also 't_vb')
    set visualbell
    set t_vb&
  elseif myeb ==? ""
    " audibly beep on error messages
    set noerrorbells
    " Screen flash on error (See also 't_vb')
    set visualbell
    set t_vb=
  endif
endfunction

Re-start Vim and enter

:call Errorbells_off("beep") -- turns off beeps
:call Errorbells_off("flash") -- turns off flashes
:call Errorbells_off() -- turns off both

We use this the Cream for Vim project (http://cream.sourceforge.net).


set noerrorbells
if has('autocmd')
  autocmd GUIEnter * set vb t_vb=
endif

The "autocmd" tip worked for me when nothing else did on VIM 6.3 / Sparc / Solaris 8.