On Tue, 10 Oct 2006 at 12:14pm, Kamil Kisiel wrote:

> I've got some C++ source code that I'd like to fold away. Basically I
> want vim to have folds only between #ifdef _DEBUG and the
> corresponding #endif statement, and nowhere else. My vimfu is a bit
> weak in this respect so I'm not quite sure how I would go about doing
> this. Using foldexpr, changing the marker type? Previously I was just
> manually creating folds, but as you can imagine it gets fairly tedious
> and it would be great if I could automate it. Your help is much
> appreciated.

If the ifdefs that you want to fold are not nested, you can use my
foldutil plugin from here:

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

You would use something like:

: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

-- 
HTH,
Hari

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

Reply via email to