Posted By

conspirator on 01/26/09


textmate applescript wrap bbedit

Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


Insert and Close Tag Script for BBEdit

 / Published in: AppleScript

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!

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

Report this snippet  

You need to login to post a comment.