Have you tried Clippings in BBEdit yet? A Clipping is just a way to quickly add a chunk of commonly used text into your document. It also works with what you have selected before choosing the clipping.

For example, you select 'a few words' in your document, choose your Double Paren Clipping and, it converts to '((a few words))'.

You can access your Clippings in the top menu under the black C icon. There's a Clippings Palette you can keep open for easy access (Window>Palettes>Clippings). Or, you can also assign a keyboard shortcut to each of your Clippings.

Your example Double Paren Clipping would just be a plain text file that contains..
    ((#SELECT#))

Make new ones by starting a new file in BBE, write your clipping and choose Save as Clipping under the Clipping icon. Under the Clippings icon you can choose Open Clippings Folder to see all your Clipping files and organize them into different Sets or subfolders.

There are a bunch of other placeholders you can use besides #SELECT# like, #FILE#, #DATE# #CLIPBOARD#, etc.

    See Chapter 12 in BBEdit Manual.

    - Den.


10/19/13 8:26 PM, [email protected] (Oliver Taylor) apparently typed:
I'm attempting to create a script that surrounds the selected text with paired 
characters - in a smart way.

For example, if you want to surround the selection with <selection> then just enter < and the script will do the right thing. I've got that working, but I'd love to make it a bit better.

For example, I might to surround the selection like this: <<<selection>>>. Or like this: #<selection># . Or like this: (( *selection* ))

Can anyone help me figure this out? Maybe this is beyond a simple script like 
this?

Here's what I've got so far...

--Display Dialog and Get Input
display dialog "Surround Selection With..." default answer ""

--Get Answer & Return Comment
set surround to (text returned of result)

tell application "BBEdit"
try
-- test to see if input has a matching character - {}()[] etc.
-- then surround the selection with the pair
if surround is in {"{"} then
set selection to "{" & selection & "}"
else if surround is in {"("} then
set selection to "(" & selection & ")"
else if surround is in {"["} then
set selection to "[" & selection & "]"
else if surround is in {"“"} then
set selection to "“" & selection & "”"
else if surround is in {"‘"} then
set selection to "‘" & selection & "’"
else if surround is in {"<"} then
set selection to "<" & selection & ">"
else
-- if there's no match then just surround with the input on both sides
set selection to surround & selection & surround
end if
end try
end tell


--
This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email
"[email protected]" 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 Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].

Reply via email to