Sunday, September 19, 2010

Re: vim visual bell

On Sat, 11 Sep 2010, Tony Mechelynck wrote:

> On 10/09/10 23:14, Long wrote:
>> Hi,
>> I followed your post on this link
>> http://groups.google.com/group/vim_use/browse_thread/thread/df79faca8997b995
>>
>>
>> and wonder, what is the t_vb that you set for the visual bell to work ?
>> the default t_vb=^[[?5h$<100/>^[[?5l
>> does not work for me.
>> I want just the visual bell.
>> my $TERM is gnome-256color, vim 7.2.330 and i am using gnome-terminal
>> 2.30.1.
>> (visual bell does work in bash + gvim so it's very bizzare for me).
>> Do you have any advice for me ?
>> Thanks.
>>
>
> (Next time, please send your questions to the mailing list, so even when I'm
> not there, anyone may try and give an answer).
>
> For visual bell only (and no beep), I use
>
> set visualbell
>
> in the vimrc. It works for me. It should work in gvim for anyone, and in
> Console Vim if your termcap and your $TERM (or 'term') are correctly set up.
> In case of termcap problems, toggling the 'ttybuiltin' option may sometimes
> (but not always) help.
>
> As I don't use gnome-terminal, I don't know the correct t_vb value for it. In
> KDE konsole I get ^[[?5h$<100/>^[[?5l and in the Linux console I get
> ^[[?5h^[[?5l$<200/> (where each of the four ^[ is an Esc character).

The problem is with gnome-terminal itself. I don't think the options
are exposed via any configuration dialogs, but using gconf-editor, you
can find:

/apps/metacity/general/visual_bell
and
/apps/metacity/general/visual_bell_type

I think that 'checking' the former should do the trick. I found the
'fullscreen' value for the latter to be a bit jarring. Changing it to
'frame_flash' looks better, IMO.


> For both visual and audible bell, I use
>
> set errorbells visualbell
> if 1 " has arithmetic evaluation
> let &t_vb = "\x07" . &t_vb
> " 0x07, or Ctrl-G, is the ASCII "Bell" character;
> " it is supposed to ring the terminal's bell.
> endif
> if has('autocmd') && has('gui')
> au GUIEnter * let &t_vb = "\<C-G>\e|50f"
> " where 50 is the flash time in milliseconds
> endif
>

I used this portion of Tony's suggestion to get this working:

let &t_vb = "\x07"

You can probably protect it in a conditional like:

if $TERM =~? 'gnome'
let &t_vb = "\x07"
endif

I tested via:

perl -lwe 'print "\a"' ; sleep 1 ; vim +'set eb vb' +'nonsense'

which should cause two flashes, the first from Perl printing a BEL
character (kind of like a control group -- should work in most terminal
emulators that support visual bells), and the second from the error within Vim.

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: