I need a macro that inserts the paragraph numbers at the beginning of all paragraphs in a document, with four digits (like "0001", "0002"), and a "tab".
I looked for if such a macro is not already in this forum, and found at least a candidate in the topic "Auto increment applescript to number paragraphs in BBEdit" (begun on 2010-03-12). Philip Spaelti proposed the following macro:
Code: Select all
# Number Paragraphs with Carets
$doc = Document.active
$text = $doc.text
$carets = $text.findAll '^\^', 'Ea'
$num = $carets.count
foreach $caret in reversed $carets
$numString = Cast To String $num
$numString.replaceAll '\d{3}$', ',\0', 'E'
$text.replaceInRange $caret.range, $numString
$num -=1
end
It seems that the "find" expression '^\^' doesn't find anything...??
I changed it to a simple "^"; this inserted some numbers in the documents, but in wrong places...
I would very much appreciate if anyone could show me a working macro.
Thank you very much in advance!
Best regard,
Nobumi Iyanaga