When i position the mouse pointer in the editor window and use three
finger scroll on trackpad the windows scroll quite haphazardly,
probably based on update time.. Is there a setting to allow scrolling
in the order the files are listed in the "Currently open Documents"
pane.
How can I set up a grep search that will repeat looping through the document until all instances have been processed?
For instance, say I've set up markers (« and ») around target source strings, and want to process thos strings to remove any characters that are not ASCII, numeric, space, or hyphen. Something like:
FIND: (?<=«)(.*?)[^- A-Za-z0-9«»]+?(.*?)(?=»)
CHANGE TO: \1\2
How can I keep it looping until no more instances are found?
> How can I set up a grep search that will repeat looping through the document until all instances have been processed?
> For instance, say I've set up markers (« and ») around target source strings, and want to process thos strings to remove any characters that are not ASCII, numeric, space, or hyphen. Something like:
> FIND: > (?<=«)(.*?)[^- A-Za-z0-9«»]+?(.*?)(?=»)
> CHANGE TO: > \1\2
> How can I keep it looping until no more instances are found?
I don't like the find and replace dialogue any more, which was changed a long while ago. First go on top of your open file (this is tricky and annoying, because we have had once a button: "search backwards" etc I never understood, why BareBones removed this). Enter your search patterns, enable grep, and click on "replace & find".
marek
-- ___________________________________________
the embassy for talented young musicians Podium International | Marek Stepanek | ms...@PodiumInternational.org http://www.PodiumInternational.org ___________________________________________
Do you mean something like "Replace All"? The default keys are Option-Command-R.
Sometimes I want to make select changes but not all so I use command-G to skip changing and find the next occurrence and command-T to make the change and find the next.
<ms...@podiuminternational.org> wrote: > On 05.01.2011 10:03 AM, Rick Gordon wrote:
>> How can I set up a grep search that will repeat looping through the >> document until all instances have been processed?
>> For instance, say I've set up markers (« and ») around target source >> strings, and want to process thos strings to remove any characters that are >> not ASCII, numeric, space, or hyphen. Something like:
>> How can I keep it looping until no more instances are found?
> I don't like the find and replace dialogue any more, which was changed a > long while ago. First go on top of your open file (this is tricky and > annoying, because we have had once a button: "search backwards" etc I never > understood, why BareBones removed this). Enter your search patterns, enable > grep, and click on "replace & find".
> the embassy for talented young musicians > Podium International | Marek Stepanek | ms...@PodiumInternational.org > http://www.PodiumInternational.org > ___________________________________________
> -- > You received this message because you are subscribed to the "BBEdit Talk" > discussion group on Google Groups. > To post to this group, send email to bbedit@googlegroups.com > To unsubscribe from this group, send email to > bbedit+unsubscribe@googlegroups.com > For more options, visit this group at > <http://groups.google.com/group/bbedit?hl=en> > If you have a feature request or would like to report a problem, please > email "supp...@barebones.com" rather than posting to the group. > Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
Replace All is not doing it. I need to click Replace All many times to complete this sort of search. I think that the (?R) recursive search indication might help, but I can't figure out its general syntax from the single example in the BBEdit manual.
------------------
On 9/24/11 at 8:03 AM -0600, Bucky Junior wrote in a message entitled "Re: Repeating a Grep Search Until It Fails":
>Do you mean something like "Replace All"? The default keys are Option-Command-R.
>Sometimes I want to make select changes but not all so I use command-G >to skip changing and find the next occurrence and command-T to make >the change and find the next.
>Bucky
>On Sat, Sep 24, 2011 at 6:16 AM, Marek Stepanek ><ms...@podiuminternational.org> wrote: >> On 05.01.2011 10:03 AM, Rick Gordon wrote:
>>> How can I set up a grep search that will repeat looping through the >>> document until all instances have been processed?
>>> For instance, say I've set up markers (« and ») around target source >>> strings, and want to process thos strings to remove any characters that are >>> not ASCII, numeric, space, or hyphen. Something like:
>>> How can I keep it looping until no more instances are found?
>> I don't like the find and replace dialogue any more, which was changed a >> long while ago. First go on top of your open file (this is tricky and >> annoying, because we have had once a button: "search backwards" etc I never >> understood, why BareBones removed this). Enter your search patterns, enable >> grep, and click on "replace & find".
>> the embassy for talented young musicians >> Podium International | Marek Stepanek | ms...@PodiumInternational.org >> http://www.PodiumInternational.org >> ___________________________________________
>> -- >> You received this message because you are subscribed to the "BBEdit Talk" >> discussion group on Google Groups. >> To post to this group, send email to bbedit@googlegroups.com >> To unsubscribe from this group, send email to >> bbedit+unsubscribe@googlegroups.com >> For more options, visit this group at >> <http://groups.google.com/group/bbedit?hl=en> >> If you have a feature request or would like to report a problem, please >> email "supp...@barebones.com" rather than posting to the group. >> Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
>-- >You received this message because you are subscribed to the >"BBEdit Talk" discussion group on Google Groups. >To post to this group, send email to bbedit@googlegroups.com >To unsubscribe from this group, send email to >bbedit+unsubscribe@googlegroups.com >For more options, visit this group at ><http://groups.google.com/group/bbedit?hl=en> >If you have a feature request or would like to report a problem, >please email "supp...@barebones.com" rather than posting to the group. >Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
On Sat, Sep 24, 2011 at 01:03:15AM -0700, Rick Gordon wrote: > How can I set up a grep search that will repeat looping through the document until all instances have been processed?
> For instance, say I've set up markers ( and ) around target source strings, and want to process thos strings to remove any characters that are not ASCII, numeric, space, or hyphen. Something like:
> FIND: > (?<= )(.*?)[^- A-Za-z0-9 ]+?(.*?)(?= )
> CHANGE TO: > \1\2
> How can I keep it looping until no more instances are found?
As you've found, you can't do a loop inside a loop with a single grep. Instead of repeating the grep manually until no matches are found, I would use a Unix Filter. Here's a Perl script that does it:
>How can I set up a grep search that will repeat looping through the >document until all instances have been processed?
>For instance, say I've set up markers (« and ») around target >source strings, and want to process thos strings to remove any >characters that are not ASCII, numeric, space, or hyphen. Something >like:
>FIND: > (?<=«)(.*?)[^- A-Za-z0-9«»]+?(.*?)(?=»)
>CHANGE TO: > \1\2
>How can I keep it looping until no more instances are found?
The following Text Filter will, so far as I can tell, do the job. I have even tried putting Chinese characters withing the guillemets. It's probably far more longwinded than it needs to be but it works.
#!/usr/local/bin/perl use strict; use encoding 'utf-8'; my $inside; while (<>) { my @chars = split //; for (@chars) { my $ord = ord; $inside = 1 if $ord == 171; $inside = 0 if $ord == 187; if ($inside) { print if $ord == 171; print if /[a-z]|[0-9]| |-/i; } else { print; } }
Unicode can be such a pain... Not my area of expertise, unfortunately. I haven't figured out yet how to fix the filter. Anyone else know the magic combination of pragmas and encodings?
On 24/09/11 at 7:38 PM -0400, Ronald J Kimball <r...@tamias.net> wrote:
>Unicode can be such a pain... Not my area of expertise, unfortunately. I >haven't figured out yet how to fix the filter. Anyone else know the magic >combination of pragmas and encodings?
Try:
use utf8;
That tells Perl that the script itself (as opposed to input/output) is UTF8.
<johndelac...@gmail.com> wrote: >At 00:34 +0100 25/9/11, John Delacour wrote:
>>#!/usr/local/bin/perl...
>Sorry! That should probably be
>#!/usr/bin/perl
>on most people's systems.
Or make it more generic;
#!/usr/bin/env perl
That will use the first perl found in $PATH.
And if you're not using the system-supplied perl, I suggest having a look at perlbrew. I also suggest not using the system-supplied perl, which implies my perlbrew suggestion.
On Sun, Sep 25, 2011 at 12:34:20AM +0100, John Delacour wrote: > The following Text Filter will, so far as I can tell, do the job. I > have even tried putting Chinese characters withing the guillemets. > It's probably far more longwinded than it needs to be but it works.
> #!/usr/local/bin/perl > use strict; > use encoding 'utf-8'; > my $inside; > while (<>) { > my @chars = split //; > for (@chars) { > my $ord = ord; > $inside = 1 if $ord == 171; > $inside = 0 if $ord == 187; > if ($inside) { > print if $ord == 171; > print if /[a-z]|[0-9]| |-/i; > } else { > print; > } > } > } > __END__
> JD
When I run this filter on your sample text, I get the following result:
I'm not sure. Both the target file and the filter script were encoded as my default UTF-8 no bom with UNIX linefeeds, but even if I change the encodings in the files it works fine. I see roughly what is happening but it's way past my bedtime and I can't tell you quite why. What have you set in Preferences for 'Default text encoding for new documents'?
In fact for Text Filters #!perl is enough, as I've just discovered from Ronald Kimball's example, and if the filter has the .pl suffix (not needed if the shebang is there) then you don't need a shebang at all, though this may change when Barebones actually admit the phenomenon.
The shebang is, of course, needed if you need to specify a particular Perl.
At 09:52 +1000 25/9/11, Charlie Garrison wrote:
>Try:
>use utf8;
>That tells Perl that the script itself (as opposed to input/output) is UTF8.
In this case it *is* the input and output that matter. That's why I used the line:
use encoding 'utf-8';
which is essential. Without it, as you can tell by trying, you get raw utf-8 bytes.
'use utf8' is very different and usually does nothing at all.
>It could be that 'utf-8' is an alias for 'utf8', so may not make any >difference, but 'utf8' is the correct value.
Have you tried it? It simply does not work, and it is NOT the correct value. The name of the charset is utf-8 or UTF-8. I think you are confusing this usage with Perl's 'use utf8', which is totally different.
>See `perldoc encoding` for all the gory details.
Gory maybe, but nowhere does it suggest you should use a charset that does not exist!
On Sun, Sep 25, 2011 at 01:24:35AM +0100, John Delacour wrote: > I'm not sure. Both the target file and the filter script were > encoded as my default UTF-8 no bom with UNIX linefeeds, but even if I > change the encodings in the files it works fine. I see roughly what > is happening but it's way past my bedtime and I can't tell you quite > why. What have you set in Preferences for 'Default text encoding for > new documents'?
These are my settings for Text Encodings:
If file's encoding can't be guessed, use: Western (Mac OS Roman)
Default text encoding for new documents: Unicode (UTF-8)
Use UTF-8 for unix script I/O is enabled.
Let me know if you have any thoughts after you've had a good night's sleep. :)
<johndelac...@gmail.com> wrote: >At 09:52 +1000 25/9/11, Charlie Garrison wrote:
>>Try:
>>use utf8;
>>That tells Perl that the script itself (as opposed to input/output) is UTF8.
>In this case it *is* the input and output that matter. That's why I used the line:
>use encoding 'utf-8';
>which is essential. Without it, as you can tell by trying, you get raw utf-8 bytes.
>'use utf8' is very different and usually does nothing at all.
I hadn't been following the thread so wasn't sure what the requirements were. Which is why I said one method was for setting encoding of the script while other was for encoding of input/output.
<johndelac...@gmail.com> wrote: >'use utf8' is very different and usually does nothing at all.
Maybe "does nothing at all" if the script itself doesn't contain unicode characters. If it does, then it certainly does something, and is quite important.
Thanks for all your suggestions. Will need to brush up on my Perl and check it out.
Also, actually my needs are a little less complex than what is been currently discussed. My idea is to build id names for every h1-h6 in a folder of documents, and my intention was to start with the text of the head, and then munge that down to strip out all punctuation and upper ascii, then replace spaces with hyphens, and then add an "x" in front of any id entries that begin with a digit.
Can anyone confirm the use and syntax of the recursive operator (?R) discussed in advanced grep topics (on p. 194 of the manual that accompanies v9.x).
------------------
On 9/24/11 at 12:21 PM -0700, Rick Gordon wrote in a message entitled "Re: Repeating a Grep Search Until It Fails":
>Replace All is not doing it. I need to click Replace All many times to complete this sort of search. I think that the (?R) recursive search indication might help, but I can't figure out its general syntax from the single example in the BBEdit manual.
> How can I set up a grep search that will repeat looping through the document until all instances have been processed?
> For instance, say I've set up markers (« and ») around target source strings, and want to process thos strings to remove any characters that are not ASCII, numeric, space, or hyphen. Something like:
> FIND: > (?<=«)(.*?)[^- A-Za-z0-9«»]+?(.*?)(?=»)
> CHANGE TO: > \1\2
> How can I keep it looping until no more instances are found?
This AppleScript loop replaces two carriage returns (\r\r} to one (\r), so just put your search and replace items in their place:
tell application "BBEdit" activate select text 1 of project window 1 open find window repeat replace "\\r\\r" using "\\r" searching in selection of project window 1 options {search mode:grep, starting at top:false, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false} end repeat end tell