> On Oct 21, 2021, at 06:47, TJ Luoma <[email protected]> wrote:
> 
> Assume a 'regular' text file.
> 
> I'd like to be able to select a word, press a key, and have all instances of 
> that word be surrounded by {brackets}.

Hey Tj,

That's not overly difficult using a bit of AppleScript.

--
Take Care,
Chris


--------------------------------------------------------
# Auth: Christopher Stone <[email protected]>
# dCre: 2021/10/21 10:33
# dMod: 2021/10/21 10:33 
# Appl: BBEdit
# Task: Enclose All Instances of the Selected Word with Curly Braces.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Enclose,@Instances, @Selected, @Word, 
@Curly, @Braces
--------------------------------------------------------

tell application "BBEdit"
    tell front text window's text
        set theWord to the selection as text
        set rePattern to "\\b" & theWord & "\\b"
        replace rePattern using "\\{&\\}" options {search mode:grep, case 
sensitive:false, starting at top:true}
    end tell
end tell

--------------------------------------------------------

-- 
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/0BC82778-B9FE-417A-A5B6-87CC90F9A397%40gmail.com.

Reply via email to