-- This script adds a number to the start of each selected line -- thus creating a numbered list in Markdown tell application "BBEdit" if selection is not "" then make new text document with properties {contents:selection} at text window 1 else say "Oops, you need to select the text." return end if tell front window set lengthList to count of lines set num to 1 set MyPrefix to "" -- work through the window getting each paragraph and adding and incrementing the number repeat while num ² lengthList select line num set MyPrefix to num & ". " as string add prefix selection prefix MyPrefix set num to num + 1 end repeat -- return the list to the old window set the_list to text 1 close active document saving no set selection to the_list end tell end tell