Sublime Forum

Customizing Wrap Paragraph

#1

Is it possible to customize which characters are used as word separators for the “Wrap Paragraph” command? I’m editing Latex files, and I often use labels such as sec:my-section and chap:my-chapter. The problem is that Wrap Paragraph treats colons as valid word separators, so Wrap Paragraph will often convert:

some long line~\ref{chap:my-chapter}

into

some long line~\ref{chap:
my-chapter}

which breaks the reference. I saw the other threads about not letting the wrapping happen around hyphens, but there does not seem to be an equivalent option for colons. I thought the “word_separators” option would control this, but it does not appear to.

0 Likes

#2

Any workarounds for this? This makes Wrap Paragraph practically useless for Latex editing…

0 Likes

#3

The built-in Wrap Paragraph command doesn’t treat colons in any special way, and the only reason it would be breaking on one is if the word is longer than the line width. In that case, if it does break at the colon, it’s just coincidence that it happened to become the last character on the line.

To change this, if you are applying the hack from this post, just add

wrapper.break_long_words = False

to the function as well. But I wouldn’t really recommend that, as your edit will get wiped out any time Sublime gets updated.

The best solution is probably to use the Wrap Plus plugin.
It’s default behaviour is ALSO to break on hyphens and long words, but it exposes a preference that lets you turn that off. Specifically, add

"WrapPlus.break_long_words": false, "WrapPlus.break_on_hyphens": false
to your user preferences (or as a syntax-specific preference for LaTeX) to get the appropriate behaviour for LaTeX.

0 Likes