Sublime Forum

A different approach for text wrapping

#1

I’ve been in search for a dynamic text wrap length depending on the length of the last word in each line, but no luck so far. Here is an example:

Instead of wrapping like this (by obeying the exact length):

                                    |
                                    |
Lorem ipsum dolor sit amet,
consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore
et dolore magna aliqua. Ut enim ad
minim veniam, quis
                                    |
                                    |

It should wrap like this:

                                    |
                                    |
Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis
                                    |
                                    |

It’s algorithm is simple: At the end of each line, check if more than half of the last word fits in the available space, if it fits then leave the whole word in that line even though this breaks the specified wrap length. And so on for the next lines.

Anybody has seen such an approach in any editor plugin?

P.S. One might say I could increase the specified wrap length by 5-10 to achive a similar effect. However the solution above gives a more satisfying vertical right border for a given block of text.

0 Likes