Return to Snippet

Revision: 11150
at January 26, 2009 12:36 by conspirator

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

Initial URL

Initial Description
I've used Textmate since I started hand-coding websites. My boss loves BBEdit. This script allows me to do the thing I missed most from Textmate creating and wrapping tags around text. Enjoy!

Initial Title
Insert and Close Tag Script for BBEdit

Initial Tags

Initial Language