On May 30, 2012, at 21:13, e2o wrote:
> Is there a way to automatically create new BBEdit documents for each chunk of
> text that is selected by a Find command? I have a document with a ton of
> multi-line chunks, with the format:
______________________________________________________________________
Hey Eric,
That's not too difficult.
If you're going to create tons of documents then you may want to write them to
disk rather than just opening new unsaved documents as I have done here.
--
Best Regards,
Chris
------------------------------------------------------------------------------------------------
try
set regEx to "^\\*(?s)[^\\*]*"
set foundFlag to true
tell application "BBEdit"
set frontDocID to ID of front text document
tell text of document id frontDocID
select insertion point before character 1
repeat while foundFlag = true
set findRecord to find regEx options {search mode:grep, case
sensitive:false} with selecting match
set foundFlag to found of findRecord
if foundFlag = true then
tell application "BBEdit" to make new document with properties
{text:contents of found object of findRecord as text}
end if
end repeat
end tell
end tell
on error eMsg number eNum
set {c, s} to {return, "------------------------------------------"}
set e to s & c & "Error: " & eMsg & c & s & c & "Error Number: " & eNum & c &
s
beep
set dDlg to display dialog e buttons {"Cancel", "Copy", "OK"} default button
"OK"
if button returned of dDlg = "Copy" then
set the clipboard to e
end if
end try
------------------------------------------------------------------------------------------------
--
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>