On Wed, 11 Oct 2006 at 1:45pm, [EMAIL PROTECTED] wrote:

> [EMAIL PROTECTED] дÓÚ 2006-10-11 12:27:33:
> > > :FoldMatching #ifdef\ _DEBUG #endif 0
> > >
> > > The last parameter is a context, so you might like 1 better than 0
> > > (allows you to see what you are folding). Alternatively, you can also
> > > configure the foldtext (see plugin page or the header in the file for
> > > information)
> > >
> > > If you want this to be automatically done everytime you open the file,
> > > then you need to create an autocommand e.g.,(untested):
> > >
> > > au FileType c FoldMatching #ifdef\ _DEBUG #endif 0
> > Hari,
> >
> > Perfect. That's exactly what I wanted, and I'm sure your script will
> > be useful in many other ways as well Good to find out about it, and
> > thanks for your work.
> >
> > --
> > Kamil Kisiel <[EMAIL PROTECTED]>
>
> I don't know how it works, but it seems that cannot cope with statements
> like the following:
>
> #ifdef _DEBUG
>     /* only things here should be folded */
> #else
>    /* these lines should NOT be folded */
> #endif
>
> or the following:
>
> #ifndef _DEBUG
>     /* these lines should NOT be folded */
> #else
>     /* only things here should be folded */
> #endif
>
> What should I do, if the #if statements may contain #else? especially for
> the latter one, the #ifndef has #else?

For the first case, you can change the end pattern.

:FoldMatching #ifdef\ _DEBUG #else 0

For the second case, it is not possible using this plugin, as you want
to fold between #else to #endif, but these can be part of any #ifdef or
#ifndef. If you are willing to add extra indicators (which is useful
in any case, especially if you have nested loops), then something like
this:

#ifndef _DEBUG
    /* these lines should NOT be folded */
#else // _DEBUG
    /* only things here should be folded */
#endif // _DEBUG

will give rise to:

:FoldMatching #else\ //\ _DEBUG #endif\ //\ _DEBUG 0

-- 
HTH,
Hari

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to