Commenting out block of lines

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Rob Nicholson

Commenting out block of lines

Post by Rob Nicholson »

I'm trying to delete out a block of lines based on a regular expression as shown below. I want to delete the following VisualBasic interface which isn't used anymore.

I've tried replacing:

Private Property Get IFeature_Templates.*End Property

with nothing but that doesn't work as . doesn't match end of lines?

Any ideas?
Thanks, Rob.

Private Property Get IFeature_Templates() As JadeObject.CCollection
Set IFeature_Templates = Product.Templates
Dim Parent As ISReqParent
Set Parent = m_Object.Parent
Set IFeature_Templates = Parent.FindProdFromRequestType(Me).Templates
End Property
Andreas

Re: Commenting out block of lines

Post by Andreas »

use \n to match linebreaks - but you can't use + or * on \n ...
Rob Nicholson

Re: Commenting out block of lines

Post by Rob Nicholson »

That's the problem isn't it :-) Even the $ character doesn't work. I'm sure there must be a way as commenting out an block of lines which are delimited by two tokens must be done quite frequently.

Cheers, Rob.
xartica

Re: Commenting out block of lines

Post by xartica »

Although TextPad is one of my most-cherished applications,
I haven't found a textpad-based solution (a suitable RegExp) for
performing interline deletions or replacements.

For these replacements (and deletions), I depend upon a program called
XReplace32. (see http://xreplace.vestris.com/ )

I've used it to bulk replace portions of HTML documents ~~ pull in a copy of HTML pages from a website I've authored, without worrying about whether each document was authored in a Unix environment or on a Windows PC
(different end-of-line chars to try to match)...

...and replace the contents of a named <div>, for instance. XReplace lets you "split" the text you're interested in replacing, so you can say "look for <div id="navbar"> and perform a replacement all the way up to, and including, the next string that matches '</div>'.

The example I gave is analagous with what you are wanting to do:

replace/nix everything between
"Private Property Get IFeature_Templates."
and
"End Property"

For every matching instance found.
Rob Nicholson

Re: Commenting out block of lines

Post by Rob Nicholson »

Thanks for the recommendation. I'll check out X-REPLACE. Maybe one for the TextPad wishlist?

Cheers, Rob.
Roy Beatty

Re: Commenting out block of lines

Post by Roy Beatty »

Forty bucks for the full version seems steep, even to a regex junkie like me! What does this utility add that Python or Perl lack?

Just curious,

Roy
Rob Nicholson

Re: Commenting out block of lines

Post by Rob Nicholson »

If X-Replace saves use just one hour of work, it's paid for itself. As non-web, Unix skilled person, I like the idea it's not Perl :-) Tried the shareware version and learnt what I needed to do in 15 mins. Not sure the same would be true of Perl.

But should we be talking about a competitor?

Rob.
Mark Schnitzius

Re: Commenting out block of lines

Post by Mark Schnitzius »

Have you considered using a macro? Just define one that searches for your ending condition (End Property) with "Extend Selection" checked, then deletes it.
Rob Nicholson

Re: Commenting out block of lines

Post by Rob Nicholson »

That's a good suggestion but requires you to visit each file one by one, running the macro. The great thing about replace is that is can very quickly replace through hundreds of source files.

Cheers, Rob.
Post Reply