Here's another AppleScript I came across for wrapping tags around a
selection.

This one is a little smarter, if I type 'p class="someclass"' for
example, it closes the end </p> tag without the class attribute on it:

tell application "BBEdit"
        set theText to text of front text document
        set theSelection to the selection as string
        set theCharStart to (characterOffset of selection)
        set theResponse to text returned of (display dialog "Wrap what tags
around selection?" default answer "" default button 2)
        set theTag to first word of theResponse
        --set theOther to chars((length of first word of theResponse) - end)
of theResponse
        set tmpStr to "<" & theResponse & ">" & theSelection & "</" & theTag
& ">"
        set the selection to tmpStr
        set insertionPosition to (theCharStart + (length of tmpStr))
        --select (characters insertionPosition through (insertionPosition -
1)) of front text document
        select insertion point before character insertionPosition of front
text document
end tell

I found this script here: 
http://snipplr.com/view/11536/insert-and-close-tag-script-for-bbedit/

On Jan 13, 12:03 pm, Ron Fleckner <ronfleck...@ozemail.com.au> wrote:
> On 13/01/2011, at 8:06 AM, Micky Hulse wrote:
>
> > Ron, I love your snippet!
>
> Thanks.  Makes the world go around, apparently.

-- 
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 bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
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 "supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to