On Dec 09, 2010, at 01:14, Maurizio Gennaro Cataldo wrote:
> I really do not figure out how to implement a sorting task which involves 
> items inside a line of text. I know that BBEdit is able to sort lines but 
> what I need is something different.
______________________________________________________________________

Hey Maurizio,

Matt's Perl snippet is quite neat.  Here's a way to do it with Applescript, but 
it requires the Satimage.osax.

Note that the SIO's 'splittext' command can use regex, so it would be easy to 
case for a missed space: "word1,word2".

--
Chris

# 
==================================================================================================
# Change Handler — Satimage.osax — 2010-09-25
# 
==================================================================================================
on cng(findText, changeText, textSource)
        change findText into changeText in textSource ¬
                with regexp without case sensitive
end cng
# 
==================================================================================================
tell application "BBEdit"
        try
                tell front text window
                        set lineNum to startLine of selection
                        set bbLineData to contents of line lineNum
                        set splitLine to splittext bbLineData using ", "
                        set splitLine to cng("(^\\d+)(.+)", "\\2•\\1", 
splitLine) of me
                        set splitLine to sortlist splitLine comparison 1
                        set splitLine to cng("(^.+)•(\\d+)", "\\2\\1", 
splitLine) of me
                        set splitLine to join splitLine using ", "
                        set contents of line lineNum to splitLine
                end tell
        on error errMsg number errNum
                beep
                tell me to display dialog "Error: " & errMsg & return & "Error 
Number: " & errNum
        end try
end tell

-- 
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>

Reply via email to