BBEdit: How to copy current paragraph to clipboard?

Is it possible to create an AppleScript for BBEdit that copies the paragraph containing the text cursor to the system clipboard?

I can get the character offset of the caret:

tell application "BBEdit"
	set cursor_loc to characterOffset of selection
end tell

But then I don’t know how to select (and copy) the paragraph that contains the caret.

Please try this

tell application "BBEdit"
	set currentLine to contents of line (startDisplayLine of selection) of document 1
end tell
set the clipboard to currentLine
1 Like

Thank you for your help.

For the record: This script requires that word-wrap is deactivated.

change the one line to

set currentLine to contents of line (startLine of selection) of document 1

It should now work with word-wrap

1 Like