disable visual bell in insert mode for PHP file

20 views
Skip to first unread message

Jon Trelfa

unread,
Dec 4, 2009, 10:52:47 PM12/4/09
to vim...@googlegroups.com
PHP's OOP style uses the "arrow" (dash + greater-than symbol) to point to methods/properties of objects.  *Something* triggers an event whenever the > is typed while I'm in insert mode - which makes my screen flash (visual bell).  Even when I *tried* to disable the visual bell using this in my .vimrc:

set vb
set t_vb=

Any ideas how/why I get a visual bell when I type that particular character when editing a PHP file?  The flashing is going to fry my brain or give me a seizure.

Thanks,

Jon

Jon Trelfa

unread,
Dec 4, 2009, 11:09:44 PM12/4/09
to vim...@googlegroups.com
To answer my own question - it turns out that the bell was a result of this line in my vimrc:

set showmatch

Apparently, showmatch looks for a matching < whenever > is typed - then briefly tries to move to the match, blink on it, then move the cursor back to where you're typing.

Now I just need to figure out how to disable showmatch for the <> characters in PHP files (there's a matchpairs in the help files, but I'm still figuring out what I can do to change it only for PHP files)

Jon

Nat Williams

unread,
Dec 5, 2009, 12:40:01 AM12/5/09
to vim...@googlegroups.com
On Fri, Dec 4, 2009 at 10:09 PM, Jon Trelfa <jtr...@gmail.com> wrote:
>
> On Fri, Dec 4, 2009 at 10:52 PM, Jon Trelfa <jtr...@gmail.com> wrote:
>>
>> PHP's OOP style uses the "arrow" (dash + greater-than symbol) to point to methods/properties of objects.  *Something* triggers an event whenever the > is typed while I'm in insert mode - which makes my screen flash (visual bell).  Even when I *tried* to disable the visual bell using this in my .vimrc:
>> set vb

I'm pretty sure this turns visualbell ON.  Try 'set novb' or 'set novisualbell'.

>>
>> set t_vb=
>> Any ideas how/why I get a visual bell when I type that particular character when editing a PHP file?  The flashing is going to fry my brain or give me a seizure.
>
> To answer my own question - it turns out that the bell was a result of this line in my vimrc:
> set showmatch
> Apparently, showmatch looks for a matching < whenever > is typed - then briefly tries to move to the match, blink on it, then move the cursor back to where you're typing.
> Now I just need to figure out how to disable showmatch for the <> characters in PHP files (there's a matchpairs in the help files, but I'm still figuring out what I can do to change it only for PHP files)
> Jon


Nat

Gary Johnson

unread,
Dec 5, 2009, 3:37:40 AM12/5/09
to vim...@googlegroups.com
On 2009-12-04, Jon Trelfa wrote:
> On Fri, Dec 4, 2009 at 10:52 PM, Jon Trelfa <jtr...@gmail.com> wrote:
>
> PHP's OOP style uses the "arrow" (dash + greater-than symbol) to point to
> methods/properties of objects. *Something* triggers an event whenever the
> > is typed while I'm in insert mode - which makes my screen flash (visual
> bell). Even when I *tried* to disable the visual bell using this in my
> .vimrc:
>
> set vb
> set t_vb=
>
> Any ideas how/why I get a visual bell when I type that particular character
> when editing a PHP file? The flashing is going to fry my brain or give me
> a seizure.

Setting t_vb= in your .vimrc won't do any good if you're using gvim.
See the note under

:help vb

You need to set it either in your .gvimrc or set it using an
autocommand in your .vimrc, like this:

set visualbell t_vb= " Turn off beep and disable visual bell.
au GuiEnter * set t_vb= " Disable visual bell again when GUI starts.

> Now I just need to figure out how to disable showmatch for the <>
> characters in PHP files (there's a matchpairs in the help files,
> but I'm still figuring out what I can do to change it only for PHP
> files)

If you want to change some setting for just PHP files, put the
changes in ~/.vim/after/ftplugin/php.vim for Unix or
~/vimfiles/after/ftplugin/php.vin for Windows. You can remove the
<> pair from 'matchpairs' with

setlocal matchpairs-=<:>

in that file. Alternatively, you could disable 'showmatch'
altogether for PHP files with this:

setlocal noshowmatch

HTH,
Gary


Spencer Collyer

unread,
Dec 5, 2009, 4:03:16 AM12/5/09
to vim...@googlegroups.com
On Fri, 4 Dec 2009 23:40:01 -0600, Nat Williams wrote:
> On Fri, Dec 4, 2009 at 10:09 PM, Jon Trelfa <jtr...@gmail.com> wrote:
> >
> > On Fri, Dec 4, 2009 at 10:52 PM, Jon Trelfa <jtr...@gmail.com>
> > wrote:
> >>
> >> PHP's OOP style uses the "arrow" (dash + greater-than symbol) to
> >> point to methods/properties of objects.  *Something* triggers an
> >> event whenever the > is typed while I'm in insert mode - which
> >> makes my screen flash (visual bell).  Even when I *tried* to
> >> disable the visual bell using this in my .vimrc: set vb
>
> I'm pretty sure this turns visualbell ON.  Try 'set novb' or 'set
> novisualbell'.
>

It does, but this following line from the OP:

> >> set t_vb=

then sets the terminal visualbell to off. If you use 'novisualbell' you
get the terminal beep, which is likely why the OP uses 'set vb' in the
first place. I suspect it's a common idiom to use something like what
the OP has done in order to turn off both visual and audio bells.

Spencer

--
<<< Eagles may soar, but weasels don't get sucked into jet engines >>>
8:59am up 99 days 15:58, 1 user, load average: 1.29, 1.37, 2.69
Registered Linux User #232457 | LFS ID 11703

Jon Trelfa

unread,
Dec 5, 2009, 2:07:19 PM12/5/09
to vim...@googlegroups.com
On Sat, Dec 5, 2009 at 3:37 AM, Gary Johnson <gary...@spocom.com> wrote:

If you want to change some setting for just PHP files, put the
changes in ~/.vim/after/ftplugin/php.vim for Unix or
~/vimfiles/after/ftplugin/php.vin for Windows.  You can remove the
<> pair from 'matchpairs' with

   setlocal matchpairs-=<:>

in that file.  Alternatively, you could disable 'showmatch'
altogether for PHP files with this:

   setlocal noshowmatch

HTH,
Gary


I used your suggestion - with a slightly different implementation.  I added this line to my .vimrc:

au BufWinEnter *.php set mps-=-<:>


Seems to have done the trick
Reply all
Reply to author
Forward
0 new messages