On 12/21/2018, at 14:16, Alex gat <[email protected]
<mailto:[email protected]>> wrote:
> I have that very long text file, made of several paragraphs. Each paragraphs
> is separated by a double carriage return (\n\n).
>
> What I'd like to do is to replace each \n\n by a number that automatically
> increase for each occurrence.
>
> What grep function should I be using in the replace text field.
Hey Alex,
Plain grep isn't up to doing the calculations for that little task.
Do I understand correctly? You want to go from this:
one
two
three
four
five
To this:
1. one
2. two
3. three
4. four
5. five
Yes?
That's easy enough to do with a little bit of Perl in a BBEdit Text Filter:
#!/usr/bin/env perl -sw
use utf8;
$/ = "\n\n";
my $cntr = 0;
while (<>) {
print ++$cntr.". ";
chomp;
print;
print "\n";
}
For details on how to work with text filters look in the user manual, but
here's the basics:
BBEdit text-filters operate on the selection if there is one, otherwise they
operate on the whole front document.
Text filters are installed here:
~/Library/Application Support/BBEdit/Text Filters/
Text filters are run from:
BBEdit Menu Bar > Text > Apply Text Filter > <your_filter>
And of course you can give them keyboard shortcuts in BBEdit's Menus &
Shortcuts preferences.
--
Best Regards,
Chris
--
This is the BBEdit Talk public discussion group. If you have a
feature request or need technical support, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <https://www.twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.