Vim Tips Wiki
(Move categories to tip template)
(Remove html character entities)
Line 48: Line 48:
 
" Screen flash on error (See also 't_vb')
 
" Screen flash on error (See also 't_vb')
 
set visualbell
 
set visualbell
set t_vb&
+
set t_vb&
 
elseif myeb ==? ""
 
elseif myeb ==? ""
 
" audibly beep on error messages
 
" audibly beep on error messages

Revision as of 08:41, 29 September 2008

Tip 418 Printable Monobook Previous Next

created February 3, 2003 · complexity basic · author Dave · version 6.0


How do you stop gvim from beeping on error?

Comments

:set vb

I tried :set vb. In a GUI, it's just murder on the eyes. I'd much rather suffer through the bells.


Paste the following function into your vimrc:

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


Removing complexity of the program. Just type following in your vimrc:

set noerrorbells
set visualbells
set t_vb=

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.