Scrolling files open in "Currently Open Documents"

96 views
Skip to first unread message

Aman

unread,
Sep 22, 2011, 11:36:54 PM9/22/11
to BBEdit Talk
Hi,

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.

Regards,

Aman

Rick Gordon

unread,
Sep 24, 2011, 4:03:15 AM9/24/11
to bbe...@googlegroups.com
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?

--
___________________________________________________

RICK GORDON
EMERALD VALLEY GRAPHICS AND CONSULTING
___________________________________________________

WWW: http://www.shelterpub.com

Marek Stepanek

unread,
Sep 24, 2011, 8:16:23 AM9/24/11
to bbe...@googlegroups.com
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:
>
> 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
___________________________________________

Bucky Junior

unread,
Sep 24, 2011, 10:03:01 AM9/24/11
to bbe...@googlegroups.com
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

> --
> 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 bbe...@googlegroups.com
> To unsubscribe from this group, send email to
> bbedit+un...@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 "sup...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
>

Rick Gordon

unread,
Sep 24, 2011, 3:21:25 PM9/24/11
to bbe...@googlegroups.com
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":

Ronald J Kimball

unread,
Sep 24, 2011, 4:33:33 PM9/24/11
to bbe...@googlegroups.com
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:

#!perl -p

s{(�)([^�]+)(�)}{my $x = $2; $x =~ tr,A-Za-z0-9 -,,cd; "$1$x$3"}ge;

__END__

This matches each occurence of �...�, and then removes the unwanted
characters within each match.

Ronald

John Delacour

unread,
Sep 24, 2011, 6:11:10 PM9/24/11
to bbe...@googlegroups.com
At 16:33 -0400 24/9/11, Ronald J Kimball wrote:

>.. Here's a Perl script that does it:


>
>#!perl -p
>
>s{(«)([^»]+)(»)}{my $x = $2; $x =~ tr,A-Za-z0-9 -,,cd; "$1$x$3"}ge;
>
>__END__


It works with this:

one «abç» two «abc∂» three «aßcdé»

but not with this:

one «a®bc» two «abc®™» three «®®a»

and the eval might make it fail on a server.

JD

John Delacour

unread,
Sep 24, 2011, 7:34:20 PM9/24/11
to bbe...@googlegroups.com
At 01:03 -0700 24/9/11, 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?

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

Ronald J Kimball

unread,
Sep 24, 2011, 7:38:08 PM9/24/11
to bbe...@googlegroups.com
On Sat, Sep 24, 2011 at 11:11:10PM +0100, John Delacour wrote:
> At 16:33 -0400 24/9/11, Ronald J Kimball wrote:
>
> >.. Here's a Perl script that does it:
> >
> >#!perl -p
> >
> >s{(«)([^»]+)(»)}{my $x = $2; $x =~ tr,A-Za-z0-9 -,,cd; "$1$x$3"}ge;
> >
> >__END__
>
>
> It works with this:
>
> one «abç» two «abc∂» three «aßcdé»
>
> but not with this:
>
> one «a®bc» two «abc®™» three «®®a»

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?


> and the eval might make it fail on a server.

I'm not sure why you think that.


Ronald

John Delacour

unread,
Sep 24, 2011, 7:39:11 PM9/24/11
to bbe...@googlegroups.com
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.

JD

Charlie Garrison

unread,
Sep 24, 2011, 7:52:21 PM9/24/11
to bbe...@googlegroups.com
Good morning,

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.


Charlie

--
Ꮚ Charlie Garrison ♊ <garr...@zeta.org.au>

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
http://www.ietf.org/rfc/rfc1855.txt

Charlie Garrison

unread,
Sep 24, 2011, 7:52:21 PM9/24/11
to bbe...@googlegroups.com
Good morning,

On 25/09/11 at 12:39 AM +0100, John Delacour
<johnde...@gmail.com> wrote:

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.

Ronald J Kimball

unread,
Sep 24, 2011, 7:54:16 PM9/24/11
to bbe...@googlegroups.com
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:

http://gyazo.com/5bc49629f7d4b0faf663634585fd6355.png

What am I doing wrong?

thanks,
Ronald

Charlie Garrison

unread,
Sep 24, 2011, 8:13:25 PM9/24/11
to bbe...@googlegroups.com
Good morning,

On 24/09/11 at 7:54 PM -0400, Ronald J Kimball <r...@tamias.net> wrote:

>When I run this filter on your sample text, I get the following result:
>
>http://gyazo.com/5bc49629f7d4b0faf663634585fd6355.png
>
>What am I doing wrong?

Rather than:

use encoding 'utf-8';

Try:

use encoding 'utf8';

It could be that 'utf-8' is an alias for 'utf8', so may not make
any difference, but 'utf8' is the correct value.

See `perldoc encoding` for all the gory details.


Charlie


PS. I can never keep clear whether to use utf8 or utf-8, so if
one doesn't work, try the other.

Ronald J Kimball

unread,
Sep 24, 2011, 8:21:37 PM9/24/11
to bbe...@googlegroups.com
On Sun, Sep 25, 2011 at 10:13:25AM +1000, Charlie Garrison wrote:
> Rather than:
>
> use encoding 'utf-8';
>
> Try:
>
> use encoding 'utf8';
>
> It could be that 'utf-8' is an alias for 'utf8', so may not make
> any difference, but 'utf8' is the correct value.

I get the same result, unfortunately. I don't know if this is a problem
with the script, or with the passing of data between the script and BBEdit.

Ronald

John Delacour

unread,
Sep 24, 2011, 8:24:35 PM9/24/11
to bbe...@googlegroups.com
At 19:54 -0400 24/9/11, Ronald J Kimball wrote:


>When I run this filter on your sample text, I get the following result:
>
>http://gyazo.com/5bc49629f7d4b0faf663634585fd6355.png
>
>What am I doing wrong?

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'?

JD

John Delacour

unread,
Sep 24, 2011, 8:20:42 PM9/24/11
to bbe...@googlegroups.com
At 09:52 +1000 25/9/11, Charlie Garrison wrote:


>>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.

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.

JD

John Delacour

unread,
Sep 24, 2011, 8:46:04 PM9/24/11
to bbe...@googlegroups.com
At 10:13 +1000 25/9/11, Charlie Garrison wrote:

>Rather than:
>
>use encoding 'utf-8';
>
>Try:
>
>use encoding 'utf8';
>
>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!

See:

<http://perldoc.perl.org/perlunifaq.html#What%27s-the-difference-between-UTF-8-and-utf8?>

<http://perldoc.perl.org/Encode.html#UTF-8-vs.-utf8-vs.-UTF8>

JD


Ronald J Kimball

unread,
Sep 24, 2011, 9:01:41 PM9/24/11
to bbe...@googlegroups.com
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. :)

Ronald

Charlie Garrison

unread,
Sep 24, 2011, 9:08:48 PM9/24/11
to bbe...@googlegroups.com
Good morning,

On 25/09/11 at 1:20 AM +0100, John Delacour
<johnde...@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.

Anyway, we're straying off topic.


Charlie

Charlie Garrison

unread,
Sep 24, 2011, 9:10:13 PM9/24/11
to bbe...@googlegroups.com
Good morning,

On 25/09/11 at 1:46 AM +0100, John Delacour
<johnde...@gmail.com> wrote:

>>See `perldoc encoding` for all the gory details.
>
>Gory maybe, but nowhere does it suggest you should use a charset that does not exist!

I was saying that based on one of the examples in the POD, specifically:

use encoding 'utf8';

I then explicity search for an example using 'utf-8' and
couldn't find one.

So I concluded that utf8 is the correct value.

Which just says that utf8 is a relaxed version of utf-8 (or utf8
vs utf-8-strict).

So both are valid, and no, utf-8 is not just an alias for utf8
as I had guessed. But for the purposes of the text filter,
either should work fine.

Charlie Garrison

unread,
Sep 24, 2011, 9:10:14 PM9/24/11
to bbe...@googlegroups.com
Good morning,

On 25/09/11 at 1:20 AM +0100, John Delacour
<johnde...@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.

Rick Gordon

unread,
Sep 24, 2011, 8:22:56 PM9/24/11
to bbe...@googlegroups.com
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.

--

Løseth Tor Rafsol

unread,
Sep 28, 2011, 3:55:25 PM9/28/11
to bbe...@googlegroups.com
On Sep 24, 2011, at 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:

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\\rusing "\\rsearching in selection of project window 1 options {search mode:grepstarting at top:falsewrap around:falsebackwards:falsecase sensitive:falsematch words:falseextend selection:false}
end repeat
end tell


Tor Rafsol Løseth
Reply all
Reply to author
Forward
0 new messages