> Also sometimes a single word will "stick out" too far. The wrap margin is set to 78...
I found that too. It happens when View> Word Wrap is also turned on. I think it wraps one character too soon, or there's some off-by-one thing happening between the wrapping code in Paragraph.py and the Python textwrap module. For me, turning off View> Word Wrap was enough to make it look right.
As SteveCooperOrg suggested, a solution for your unique wrapping preference is possible by working with the wrapping code, particularly how it selects text in expandToParagraph. I haven't dug into it too much but would like to at some point.
Not directly related to your question but more to the subject of the thread, I did change the code to leave a single selection at the end of the paragraph though, instead of leaving everything selected. After the last for loop (for s in view.sel()) but within the previous if (if len(paragraphs) >)) I added this block:
- Code: Select all
# TF code to leave cursor at end of wrapped paragraph
nEnd = s.end() - 1
This clears all selections, then reuses the final selection from the for loop to create a new selection point at the end of the last line, before the final newline. This leaves the cursor in position to continue typing, instead of trying to leave the cursor at its previous position as Jon mentions in his comment in that code.
I imagine there is a better way to put the cursor at the end of the last paragraph, but as a newbie to Sublime Text coding, that's what I came up with. Suggestions of better ways would be much appreciated.