Search, start at top and other things

221 views
Skip to first unread message

Bernardo

unread,
Jan 17, 2018, 8:35:32 AM1/17/18
to BBEdit Talk
Just upgraded BBEdit from 9.6 to 12... Lots of nice features, but searching/replacing text aren't now convenient!

I loved to use cmd-F to start searching *from the top* of the document, wherever insertion point is. With old versions, I remember this advanced setting could be use:
defaults write com.barebones.bbedit FindDialog:RememberStartAtTop -bool YES
but it no longer seem to work :(

Modal dialog for search/replace text was also very convenint. There is no way to have this option again, like in old versions?

Another very anoying thing: I'm using several Clipping sets and I can't figure how to display only one set in a clipping palette (instead of having all clippings in a huge palette). Clippings management was more convenient in 9 version.

Thank you.

Rich Siegel

unread,
Jan 17, 2018, 8:50:07 AM1/17/18
to bbe...@googlegroups.com
On 1/17/18 at 7:24 AM, issa...@gmail.com (Bernardo) wrote:

>I loved to use cmd-F to start searching *from the top* of the
>document, wherever insertion point is. With old versions, I remember
>this advanced setting could be use: defaults write
>com.barebones.bbedit FindDialog:RememberStartAtTop -bool YES but it no
>longer seem to work :(
>
>Modal dialog for search/replace text was also very convenint. There is
>no way to have this option again, like in old versions?

It's a pretty dead issue. If you search the list archives for
"start at top" you can see the discussion, which includes
workable alternative strategies. (Do note that the option to use
the modal dialog went away in BBEdit 10.0.)

R.
--
Rich Siegel Bare Bones Software, Inc.
<sie...@barebones.com> <http://www.barebones.com/>

Someday I'll look back on all this and laugh... until they
sedate me.

Bernardo

unread,
Jan 18, 2018, 11:54:48 AM1/18/18
to BBEdit Talk
Concerning start searching at top in the frontmost document, I performed this search before my first post but only found users asking the same feature.
I just did a new search without finding any workaround, only the "Wrap around" option, which is different.
Some users say to look into an option in the Search dialog, but they are old posts, with the old modal dialog.

So, it is no longer possible to seach a documlent directly from its top?

Than you.

Rich Siegel

unread,
Jan 18, 2018, 12:37:36 PM1/18/18
to bbe...@googlegroups.com
On 1/18/18 at 11:49 AM, issa...@gmail.com (Bernardo) wrote:

>So, it is no longer possible to seach a documlent directly from its top?

You can still do so - the "Start at Top" option is gone, but you can:

- press Command-up-arrow to jump to the beginning of the
document before searching;

- use "Find All" to find all occurrences in the document, and
then select the first occurrence in the result list;

Live Match, and highlighting matches of the selected text will
also search the entire document from the beginning.

Bernardo

unread,
Jan 19, 2018, 9:13:55 AM1/19/18
to BBEdit Talk
Don't you think a checkbox for "Start at top" in the Search/Replace dialog would be more convenient?
Live Search is great, but it's another kind of Search.

Bernardo

unread,
Jan 20, 2018, 8:52:51 AM1/20/18
to BBEdit Talk
OK, I found this applescript that could do the job but, as I'm a total applescript newbie, I don't know how to retreive the last search string (the one which populate the built-in search dialog). This prev search should replace in the following PREV_SEARCH_STRING script.

Thanks for your help.


(*
This Applescript lets you do a search starting at the top of the current document, NOT where the cursor is currently positioned
Author: Ryan Wilcox
Date: June 17, 2014
License: Public Domain
*)

tell application "BBEdit"
    set theChoice to display dialog "Search current document for:" default answer PREV_SEARCH_STRING
   
    if button returned of theChoice is "OK" then
        set searchOpt to {starting at top:true, wrap around:false}
        set oldSearchString to text returned of res
        tell window 1
            set findRes to find (text returned of res) options searchOpt with selecting match
            if findRes's found is false then beep
        end tell
    end if
end tell

John Muccigrosso

unread,
Jan 21, 2018, 10:56:35 AM1/21/18
to BBEdit Talk
I'm working with a slightly earlier version of BBEdit, but AppleScript editor's dictionary for BBEdit shows a "current search strings" property, so try this at the start of the script:

        set PREV_SEARCH_STRING to current search strings

       set PREV_SEARCH_STRING to search string of PREV_SEARCH_STRING



 I can't seem to directly: 

set PREV_SEARCH_STRING to search string of PREV_SEARCH_STRING


Bernardo

unread,
Jan 22, 2018, 9:34:40 AM1/22/18
to BBEdit Talk
Thanks for your reply, John.
Unfortunately, Applescript editor complains about an expected end of line on the word "search" at the first line... I don't know why.

John Muccigrosso

unread,
Jan 22, 2018, 11:27:43 AM1/22/18
to BBEdit Talk
Me either. It could be just a weird copy-paste thing. Try typing it in by hand, or maybe it's the more recent version of BBEdit? For that, use command-shift-O to open BBEdit's dictionary in the script editor and make sure those properties are still there. Meanwhile, this works for me:

tell application "BBEdit"

       set PREV_SEARCH_STRING to current search strings

       

       set PREV_SEARCH_STRING to search string of PREV_SEARCH_STRING

       

       set theChoice to display dialog "Search current document for:" default answer PREV_SEARCH_STRING

       

       if button returned of theChoice is "OK" then

               set searchOpt to {starting at top:true}

               tell window 1

                       set findRes to find text returned of theChoice options searchOpt with selecting match

                       if findRes's found is false then beep

                       set search string of current search strings to findRes

               end tell

       end if

end tell



For some reason BBEdit doesn't remember the search string if you change it in the dialog.


Bernardo

unread,
Jan 22, 2018, 1:04:44 PM1/22/18
to BBEdit Talk
Thanks John.
This version works :)

property startAtTop : true
property wrapAround
: false
property caseSensitive
: false
property matchWords
: false
-----------------------------------------------------------------------------

tell application
"BBEdit"
   
--------------------------------- set prev search string
   
set prevSearchString to current search strings
   
try -- prev search string not always exists
       
set prevSearchString to search string of prevSearchString
    on error
       
set prevSearchString to ""
   
end try
   
-------------------------------- perform search
   
set theChoice to display dialog "Search current document for:" default answer prevSearchString
   
if button returned of theChoice is "OK" then
       
set searchOpt to {starting at top:startAtTop, wrap around:wrapAround, backwards:false, case sensitive:caseSensitive, match words:matchWords}

        tell window
1
           
set findRes to find text returned of theChoice options searchOpt with selecting match
           
if findRes
's found is false then beep
            --set search string of current search strings to findRes -- seems useless

Christopher Stone

unread,
Feb 4, 2018, 9:44:58 PM2/4/18
to BBEdit-Talk
On 01/21/2018, at 09:56, John Muccigrosso <jmuc...@gmail.com> wrote:
I can't seem to directly: 
set PREV_SEARCH_STRING to search string of PREV_SEARCH_STRING


Hey John,

Under some circumstances you have to expand the property before you can get to the sub-properties:

tell application "BBEdit"
    set PREV_SEARCH_STRING to search string of (get current search strings)
end tell

--
Best Regards,
Chris

Jean-Christophe Helary

unread,
Feb 7, 2018, 2:04:53 AM2/7/18
to bbe...@googlegroups.com


> On Feb 5, 2018, at 11:44, Christopher Stone <listm...@suddenlink.net> wrote:
>
>> I can't seem to directly:
>> set PREV_SEARCH_STRING to search string of PREV_SEARCH_STRING
>
> Hey John,
>
> Under some circumstances you have to expand the property before you can get to the sub-properties:

How can one know in which case that it is necessary?

> tell application "BBEdit"
> set PREV_SEARCH_STRING to search string of (get current search strings)
> end tell
>

Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune


Christopher Stone

unread,
Mar 3, 2018, 8:00:50 PM3/3/18
to BBEdit-Talk
On 02/06/2018, at 23:50, Jean-Christophe Helary <jean.christ...@gmail.com> wrote:
On Feb 5, 2018, at 11:44, Christopher Stone <listm...@suddenlink.net> wrote:
Under some circumstances you have to expand the property before you can get to the sub-properties:

How can one know in which case that it is necessary?


Hey Jean-Christophe,

There's no definitive means to determine this other than experimentation.

I never use “get” unless I get results other than what I think are kosher from a command – then I try using a “get”.

--
Take Care,
Chris

Zax

unread,
Dec 9, 2024, 9:45:20 AM12/9/24
to BBEdit Talk
With Applescript, is there a way to *set* search string of current search strings to a value?
After a custom search with an Applescript, I would like to update this BBEdit property in order to use "Find next" menu item.

Thank you.

Zax

unread,
Dec 9, 2024, 10:01:15 AM12/9/24
to BBEdit Talk
I found a solution  by creating a temporary record:

set prevReplacementString to (replacement string of (get current search strings))
if (prevReplacementString is missing value) then set prevReplacementString to ""
set searchRecord to {search string:prevSearchString, replacement string:prevReplacementString}
set current search strings to searchRecord
Reply all
Reply to author
Forward
0 new messages