Hi Tony,
    thanks for your answer. I installed matchit.vim plugin. It's working for 
the HTML tags,
but not for the C code (example I gave in my original post). 
I sourced matchit.vim explicitly from vim(to rule out the possibility that it 
isn't getting sourced), still it didn't work for C code.
What could be wrong? I'm using vim 7.1 on Windows XP.

Thanks,
Mahendra

--- On Wed, 11/2/09, Tony Mechelynck <[email protected]> wrote:
From: Tony Mechelynck <[email protected]>
Subject: Re: Using % key to find matching brace: how to exclude commented out 
code ?
To: [email protected]
Cc: [email protected]
Date: Wednesday, 11 February, 2009, 12:42 AM

On 10/02/09 12:32, Mahendra Ladhe wrote:
> Hi,
> when I use the '%' key to find matching brace('{' or
'}') in a C program,
> vim includes the code which is commented out to find the matching brace.
> e.g.
>
> 1 #include <stdio.h>
> 2
> 3 int main(int argc, char* argv[])
> 4 {
> 5 int i=10;
> 6 /* } */
> 7 return 0;
> 8 }
>
> If the cursor is on line 4 under '{' and I press the '%'
key, the cursor
> shows
> the matching closing brace on line 6 (which is commented out) and not
> the matching
> closing brace on line 8.
>
> Is there any workaround for this?
>
> Thanks,
> Mahendra

Install the matchit plugin, see ":help matchit-install". (It
doesn't 
match between inside and outside comments, and it can match much more 
than single characters.) You may also, once you have installed it, add

        au FileType c,cpp,css,javascript
                \ let b:match_words = &matchpairs

to your vimrc, in order to use matchit for these file types instead of 
default matching, but with the same matches. (The ftplugins for many 
filetypes set matchit settings if the matchit plugin is found to have 
been loaded.)


Best regards,
Tony.
-- 
        INVENTORY
Four be the things I am wiser to know:
Idleness, sorrow, a friend, and a foe.

Four be the things I'd been better without:
Love, curiosity, freckles, and doubt.

Three be the things I shall never attain:
Envy, content, and sufficient champagne.

Three be the things I shall have till I die:
Laughter and hope and a sock in the eye.





      Check out the all-new Messenger 9.0! Go to http://in.messenger.yahoo.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to