Highlight of matching brackets

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Highlight of matching brackets

Giorgos Gaganis
Hello

I am using vim to edit jsp files and it would be really usefull when
placing the cursor on an bracket vim to highlight the corresponding bracket.

Any ideas on how to achieve that.

Thank you very much
Giorgos
Reply | Threaded
Open this post in threaded view
|

Re: Highlight of matching brackets

Groleo Marius
On 8/24/05, Giorgos Gaganis <[hidden email]> wrote:

> Hello
>
> I am using vim to edit jsp files and it would be really usefull when
> placing the cursor on an bracket vim to highlight the corresponding bracket.
>
> Any ideas on how to achieve that.
>
> Thank you very much
> Giorgos
>

http://vim.sourceforge.net/tips/tip.php?tip_id=177


--
Regards, Groleo!

# touch universe
# chmod +x universe
# ./universe
Reply | Threaded
Open this post in threaded view
|

Re: Highlight of matching brackets

Steve Hall-4
In reply to this post by Giorgos Gaganis
On Wed, 2005-08-24 at 14:00 +0300, Giorgos Gaganis wrote:
>
> I am using vim to edit jsp files and it would be really usefull when
> placing the cursor on an bracket vim to highlight the corresponding
> bracket.

Like :help 'showmatch ?


--
Steve Hall  [ digitect mindspring com ]


Reply | Threaded
Open this post in threaded view
|

RE: Highlight of matching brackets

Bouckaert, Hugo
In reply to this post by Giorgos Gaganis
Hi

I found a vim plugin that does this. You may want to try it.  

http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs

However, I also have a vim script to highlight the current line:

http://www.vim.org/scripts/script.php?script_id=555

But when I turn on highlight current line, highlight matching brackets
no longer works.

Is there a highlight current line vim plugin which can work together
with highlight matching brackets? Also: the highlight current line
script from the above URL sets the line to blue. What would be really
nice is that the highlighted current line would just make the current
line a shade darker than whatever your background is - that way all your
other highlighting colors work virtually the same on that line as with
other lines.

Anybody knows of such a script that can do those two things?

Thanks

Hugo

-----Original Message-----
From: Steve Hall [mailto:[hidden email]]
Sent: Thursday, 25 August 2005 9:42 AM
To: Giorgos Gaganis
Cc: [hidden email]
Subject: Re: Highlight of matching brackets

On Wed, 2005-08-24 at 14:00 +0300, Giorgos Gaganis wrote:
>
> I am using vim to edit jsp files and it would be really usefull when
> placing the cursor on an bracket vim to highlight the corresponding
> bracket.

Like :help 'showmatch ?


--
Steve Hall  [ digitect mindspring com ]


Reply | Threaded
Open this post in threaded view
|

RE: Highlight of matching brackets

adah
In reply to this post by Giorgos Gaganis
> I found a vim plugin that does this. You may want to try it.
>
> http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs

I really found the HiMtchBrkt.vim script a little buggy.  It prohibits my
gVim for Windows cursor from moving from the end of a line to the
beginning of the next one, and, what is really worse, sometimes it makes
the cursor jump unexpectedly and even modifies the text when I just use
the movement keys (but this does not happen with h, j, k, l).

Best regards,

Yongwei
Reply | Threaded
Open this post in threaded view
|

RE: Highlight of matching brackets

Bouckaert, Hugo
In reply to this post by Giorgos Gaganis
Hi

Yes, come to think of it - I had all these problems compiling some
pl/sql just now and the errors were extra bits of text here and there -
I thought it was something I did, but perhaps it is HiMtchBrkt.vim.
That's a shame, because highlighting matching brackets would be very
useful to me.

Is there another vim plugin somewhere that highlights matching brackets?

Thanks

Hugo
   

-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
Sent: Thursday, 25 August 2005 12:49 PM
To: [hidden email]
Subject: RE: Highlight of matching brackets

> I found a vim plugin that does this. You may want to try it.
>
> http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs

I really found the HiMtchBrkt.vim script a little buggy.  It prohibits
my gVim for Windows cursor from moving from the end of a line to the
beginning of the next one, and, what is really worse, sometimes it makes
the cursor jump unexpectedly and even modifies the text when I just use
the movement keys (but this does not happen with h, j, k, l).

Best regards,

Yongwei
Reply | Threaded
Open this post in threaded view
|

RE: Highlight of matching brackets

Charles E Campbell Jr
Quoting "Bouckaert, Hugo" <[hidden email]>:
> Yes, come to think of it - I had all these problems compiling some
> pl/sql just now and the errors were extra bits of text here and there -
> I thought it was something I did, but perhaps it is HiMtchBrkt.vim.
> That's a shame, because highlighting matching brackets would be very
> useful to me.

Would someone please provide me with a repeatable example of this?  It'd
sure help with fixing it!  (first I've heard about it, actually)

Regards,
Chip Campbell

Reply | Threaded
Open this post in threaded view
|

RE: Highlight of matching brackets

Keith W. Roberts
 

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Thursday, August 25, 2005 7:33 AM
> To: Bouckaert, Hugo
> Cc: [hidden email]; [hidden email]
> Subject: RE: Highlight of matching brackets
>
> Quoting "Bouckaert, Hugo" <[hidden email]>:
> > Yes, come to think of it - I had all these problems compiling some
> > pl/sql just now and the errors were extra bits of text here
> and there -
> > I thought it was something I did, but perhaps it is HiMtchBrkt.vim.
> > That's a shame, because highlighting matching brackets would be very
> > useful to me.
>
> Would someone please provide me with a repeatable example of
> this?  It'd
> sure help with fixing it!  (first I've heard about it, actually)
>
> Regards,
> Chip Campbell

The bit (from Adah) about the cursor not crossing eol/bol at least is
obvious; you must :set whichwrap somewhere w/o restoring it on exit (or
utilize something else which does so).  Every time I've had that problem, it
turns out that something has changed &ww.

-Keith


Reply | Threaded
Open this post in threaded view
|

Re: Highlight of matching brackets

Giorgos Gaganis
In reply to this post by Charles E Campbell Jr
[hidden email] wrote:

>Quoting "Bouckaert, Hugo" <[hidden email]>:
>  
>
>>Yes, come to think of it - I had all these problems compiling some
>>pl/sql just now and the errors were extra bits of text here and there -
>>I thought it was something I did, but perhaps it is HiMtchBrkt.vim.
>>That's a shame, because highlighting matching brackets would be very
>>useful to me.
>>    
>>
>
>Would someone please provide me with a repeatable example of this?  It'd
>sure help with fixing it!  (first I've heard about it, actually)
>  
>
Hi
It has also happened to me but it happened very enexpectedly. It is
inded very strange and upredictable.
I can confirm that this problem does exist.

Giorgos

>Regards,
>Chip Campbell
>
>
>
>  
>

Reply | Threaded
Open this post in threaded view
|

RE: Highlight of matching brackets

adah
In reply to this post by Giorgos Gaganis
> Would someone please provide me with a repeatable example of this?
> It'd sure help with fixing it!  (first I've heard about it, actually)

Hi Dr Chip,

Since I can see no evidence you have received my reply to your personal
message to me (anti-spam killed it?), I am replying again here.  My
previous response was:

-----------------------------------------------------------------------
Sadly the problem is still there.  However, I feel that it is not
necessarily your problem.  Errors are accompanie by beep sounds and
extra uninput characters (like `d' or `r'), and I guess it is related
with the fact that arrow-keys generate multi-byte key sequences.

BTW, I remember I mentioned to you spaces in passwords can cause
problems in netrw.vim.  How's the situation now?
-----------------------------------------------------------------------

For me, moving the cursor back and forth in this small piece of code can
cause the problem to appear:

-----------------------------------------------------------------------
int main(int argc, char* argv[])
{
        if (...) {
                test();
        }
}
-----------------------------------------------------------------------

It does not occur always, but on my box it will occur after a while.  I
have not seen the problem occur with `h', `j', `k', and `l', but only
with the arrow keys.

My machine is quite slow (Celeron 550MHz, which I feel may count),
running Chinese version of Windows 2000.  The following files are
currently under my vimfiles\plugin directory:

HiMtchBrkt.vim
cecutil.vim
cvsmenu.vim
genutils.vim
matrix.vim
multvals.vim
pdftk.vim
project.vim
taglist.vim

Best regards,

Yongwei
Reply | Threaded
Open this post in threaded view
|

RE: Highlight of matching brackets

Keith W. Roberts
 

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Sunday, August 28, 2005 8:38 PM
> To: [hidden email]
> Subject: RE: Highlight of matching brackets
>
> > Would someone please provide me with a repeatable example of this?
> > It'd sure help with fixing it!  (first I've heard about it,
> actually)
>
> Hi Dr Chip,
>
> Since I can see no evidence you have received my reply to
> your personal
> message to me (anti-spam killed it?), I am replying again here.  My
> previous response was:
>
> --------------------------------------------------------------
> ---------
> Sadly the problem is still there.  However, I feel that it is not
> necessarily your problem.  Errors are accompanie by beep sounds and
> extra uninput characters (like `d' or `r'), and I guess it is related
> with the fact that arrow-keys generate multi-byte key sequences.
>
> BTW, I remember I mentioned to you spaces in passwords can cause
> problems in netrw.vim.  How's the situation now?
> --------------------------------------------------------------
> ---------
>
> For me, moving the cursor back and forth in this small piece
> of code can
> cause the problem to appear:
>
> --------------------------------------------------------------
> ---------
> int main(int argc, char* argv[])
> {
>         if (...) {
>                 test();
>         }
> }
> --------------------------------------------------------------
> ---------
>
> It does not occur always, but on my box it will occur after a
> while.  I
> have not seen the problem occur with `h', `j', `k', and `l', but only
> with the arrow keys.
>
> My machine is quite slow (Celeron 550MHz, which I feel may count),
> running Chinese version of Windows 2000.  The following files are
> currently under my vimfiles\plugin directory:
>
> HiMtchBrkt.vim
> cecutil.vim
> cvsmenu.vim
> genutils.vim
> matrix.vim
> multvals.vim
> pdftk.vim
> project.vim
> taglist.vim
>
> Best regards,
>
> Yongwei

Let me toss in a random $0.02 worth until someone comes up with something
better. :)  What you describe does indeed sound like escape sequences being
split up, which I suppose could happen on a slow pc being asked to do a lot
at once.  You might try fiddling with the various timeouts:

:h 'timeout' (and 'ttimeout')
:h 'timeoutlen' ('ttimeoutlen')

-Keith


Reply | Threaded
Open this post in threaded view
|

RE: Highlight of matching brackets

adah
In reply to this post by Giorgos Gaganis
Keith W. Roberts wrote:

> Let me toss in a random $0.02 worth until someone comes up with
> something better. :)  What you describe does indeed sound like escape
> sequences being split up, which I suppose could happen on a slow pc
> being asked to do a lot at once.  You might try fiddling with the
> various timeouts:
>
> :h 'timeout' (and 'ttimeout')
> :h 'timeoutlen' ('ttimeoutlen')

Hi Keith,

I think your idea might be correct, but the cure might not.  I am
guessing that the problem is that the sequence generated from
HiMtchBrkt.vim is mixed up with my own keying.  Maybe Bram can tell us
whether this is possible in theory.

(I also tried replacing lines like `inoremap <silent> <down> <down>...' to
`inoremap <silent> <down> j...' in HiMtchBrkt.vim, and it seemed the
problem appeared even more rarely, but it still did not vanish.)

Best regards,

Yongwei
Reply | Threaded
Open this post in threaded view
|

RE: Highlight of matching brackets

Keith W. Roberts
 

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Monday, August 29, 2005 8:23 PM
> To: [hidden email]
> Subject: RE: Highlight of matching brackets
>
> Keith W. Roberts wrote:
>
> > Let me toss in a random $0.02 worth until someone comes up with
> > something better. :)  What you describe does indeed sound
> like escape
> > sequences being split up, which I suppose could happen on a slow pc
> > being asked to do a lot at once.  You might try fiddling with the
> > various timeouts:
> >
> > :h 'timeout' (and 'ttimeout')
> > :h 'timeoutlen' ('ttimeoutlen')
>
> Hi Keith,
>
> I think your idea might be correct, but the cure might not.  I am
> guessing that the problem is that the sequence generated from
> HiMtchBrkt.vim is mixed up with my own keying.  Maybe Bram can tell us
> whether this is possible in theory.

Ah!  You might have hit upon something here; you might be remapping
something used by the plugin.  Try invoking vim without any of your
customizations:

        gvim -u NONE -U NONE

This should (IIUC) load plugins, etc., but not .vimrc or .gvimrc.  Check to
see that HiMtchBrkt.vim is loaded and try what you were doing before.  If it
works fine, then you know it's something of yours which bolluxed things.
Then you can list maps, abbrevs, etc. to see what is used by the plugins
that you have inadvertently usurped.

> (I also tried replacing lines like `inoremap <silent> <down>
> <down>...' to
> `inoremap <silent> <down> j...' in HiMtchBrkt.vim, and it seemed the
> problem appeared even more rarely, but it still did not vanish.)

I think "seemed" is appropriate here, as the whole purpose of the "nore" in
inoremap is to *not* reinterpret <down> *inside* the map, or in anything
invoked by the map. :)  Besides, the map as you have shown it won't work,
because in Input mode, 'j' will insert the letter 'j', whereas <down> moves
down one line.  You would have had to use <c-o>j instead.

-Keith



Reply | Threaded
Open this post in threaded view
|

Re: Highlight of matching brackets

A.J.Mechelynck
----- Original Message -----
From: "Keith W. Roberts" <[hidden email]>
To: <[hidden email]>; <[hidden email]>
Sent: Tuesday, August 30, 2005 5:45 PM
Subject: RE: Highlight of matching brackets


>
>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]]
>> Sent: Monday, August 29, 2005 8:23 PM
>> To: [hidden email]
>> Subject: RE: Highlight of matching brackets
>>
>> Keith W. Roberts wrote:
>>
>> > Let me toss in a random $0.02 worth until someone comes up with
>> > something better. :)  What you describe does indeed sound
>> like escape
>> > sequences being split up, which I suppose could happen on a slow pc
>> > being asked to do a lot at once.  You might try fiddling with the
>> > various timeouts:
>> >
>> > :h 'timeout' (and 'ttimeout')
>> > :h 'timeoutlen' ('ttimeoutlen')
>>
>> Hi Keith,
>>
>> I think your idea might be correct, but the cure might not.  I am
>> guessing that the problem is that the sequence generated from
>> HiMtchBrkt.vim is mixed up with my own keying.  Maybe Bram can tell us
>> whether this is possible in theory.
>
> Ah!  You might have hit upon something here; you might be remapping
> something used by the plugin.  Try invoking vim without any of your
> customizations:
>
> gvim -u NONE -U NONE
>
> This should (IIUC) load plugins, etc., but not .vimrc or .gvimrc.  Check
> to
> see that HiMtchBrkt.vim is loaded and try what you were doing before.  If
> it
> works fine, then you know it's something of yours which bolluxed things.
> Then you can list maps, abbrevs, etc. to see what is used by the plugins
> that you have inadvertently usurped. [...]

with -u NONE, plugins won't load. Try

    gvim -N -u NORC -U NONE

instead.


Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

RE: Highlight of matching brackets

adah
In reply to this post by Giorgos Gaganis
Keith W. Roberts wrote:

>> I think your idea might be correct, but the cure might not.  I am
>> guessing that the problem is that the sequence generated from
>> HiMtchBrkt.vim is mixed up with my own keying.  Maybe Bram can tell
>> us whether this is possible in theory.
>
> Ah!  You might have hit upon something here; you might be remapping
> something used by the plugin.  Try invoking vim without any of your
> customizations:
>
>                gvim -u NONE -U NONE
>
> This should (IIUC) load plugins, etc., but not .vimrc or .gvimrc.
> Check to see that HiMtchBrkt.vim is loaded and try what you were doing
> before.  If it works fine, then you know it's something of yours which
> bolluxed things.  Then you can list maps, abbrevs, etc. to see what is
> used by the plugins that you have inadvertently usurped.

I used `gvim -N -u NORC -U NONE' as Tony suggested.  The problem still
occurs, though it `seemed' to occur less often (one of headaches is that
I cannot reproduce the problem reliably).

>> (I also tried replacing lines like `inoremap <silent> <down>
>> <down>...' to `inoremap <silent> <down> j...' in HiMtchBrkt.vim, and
>> it seemed the problem appeared even more rarely, but it still did not
>> vanish.)
>
> I think "seemed" is appropriate here, as the whole purpose of the
> "nore" in inoremap is to *not* reinterpret <down> *inside* the map, or
> in anything invoked by the map. :)  Besides, the map as you have shown
> it won't work, because in Input mode, 'j' will insert the letter 'j',
> whereas <down> moves down one line.  You would have had to use <c-o>j
> instead.

You are right.  My change was wrong (and `j' etc. are already used for
normal-mode mappings) and did not take effect in the test at all.

Best regards,

Yongwei