On 04/14/2021, at 11:28, Rich Siegel <[email protected] 
<mailto:[email protected]>> wrote:
> This should work:
> 
>       tell app "BBEdit"
>               activate
>               open file_path
>               select insertion point after last character of document 1
>       end tell
> 
> (It's best to always target documents, rather than windows; though that's not 
> the proximate issue here. "document 1" is always the active document.)


Hey Folks,

Here's another method:

tell application "BBEdit"
    tell text of front document
        select insertion point after it
    end tell
end tell

I nearly always prefer to use tell-blocks to reference objects rather than 
one-liners, because frequently when I forget to do so I end up having to 
refactor my code when I add or change something.

For this use-case I might do something like this:

tell application "BBEdit"
    tell front document
        tell its text to select insertion point after it
    end tell
end tell

But if I will take time to write the code “correctly”:

tell application "BBEdit"
    tell front document
        tell its text
            select insertion point after it
        end tell
    end tell
end tell

Then I have no problem coming back in later and doing more with either the 
document, or the text, or both.

Probably 8 times out of 10 I'll regret not using the above construct, because a 
short time later I'll be modifying it to something on the order of this:

tell application "BBEdit"
    tell front document
        tell its text
            set after it to linefeed & "Some more text..."
            select insertion point after it
        end tell
    end tell
end tell

--
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 here. Follow @bbedit on Twitter: <https://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 view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/F3E41D7C-4B81-4927-AC38-861DCD9EC0A1%40gmail.com.

Reply via email to