On Sat, 29 Apr 2006 at 4:12pm, cga2000 wrote:

> Is there any way I could use folding to do this:
>
> 1. Fold all lines in a file that contain only comments.
>
> 2. Optionally delete all the lines that have previously been folded.
>
> I have a feeling I am looking for something less sophisticated than the
> fold feature where I could remove all lines that contain a given pattern
> - say, # or /* in col. 1, from a buffer and I am not sure folding is
> the feature I should be looking at.
>
> An example of possible use:
>
> I would find this useful when trying to prune some configuration file
> that has some ten lines of comments for every entry so that I can have
> more or less the entire configuration file fit on one screen instead of
fifteen
> or twenty.
>
> A more general definition of this need/problem might be to 'remove all lines
> that match a certain pattern from the buffer - and optionally from the file
> itself'.
>
> Thanks.
>
> cga
>
>

You might want to try my foldutil.vim and multiselect.vim plugins. The
foldutil plugin provides a feature to fold all lines that match a syntax
group (among others), so you will use the command:

:FoldShowHiGroup! Comment 0

in this case. The last argument is for context.

The other feature you might find useful is the multiselect.vim to select
lines by syntax matching, so you would use:

:MSMatchAddBySynGroup Comment

Followed by:

:MSExecNormalCmd d

to delete all these lines. I somehow thought I added a command to
convert the current folds to multi-selections, but I apparently didn't
so these two don't work together, yet.

-- 
HTH,
Hari

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

Reply via email to