Rewrap
Rewrap copied to clipboard
Feature Request: Rewrap option so line ends at a period for LaTeX text
It can be useful to end each sentence with a period and then a newline in LaTeX, for example when storing the .tex files in a git repo (minimize diffs) or when just diff'ing .tex files in general. This is especially useful within paragraphs.
So, using this optional feature, rewrapping a paragraph would look like this:
| Before | Rewrapped |
|---|---|
| This is a sentence. And this is another sentence that is too long. Short sentence. A sentence starting on the same line. Followed by one more. |
This is a sentence. And this is another sentence that is too long. Short sentence. A sentence starting on the same line. Followed by one more. |
Currently, to replicate this functionality, the user needs to carefully select each sentence in a paragraph that already has a newline after the sentence period and then hit Alt+Q. This is error prone, so this proposed feature request would be very useful.
Hi, while this is doable, I feel it's quite a specific request. So I'm reluctant to add this feature until more people request it too.
Understood.
For reference, amongst many others:
https://stackoverflow.com/a/6190412
Thanks for that.
I know it's not everything you want, but would it be ok if it simply preserved existing newlines after a '.'? So you have to make sure you write one-sentence-per-line yourself, but then Rewrap will keep that:
| Before | Rewrapped |
|---|---|
| This is a sentence. And this is another sentence that is too long. Short sentence. A sentence starting on the next line. Followed by one more. |
This is a sentence. And this is another sentence that is too long. Short sentence. A sentence starting on the next line. Followed by one more. |
I can easily roll that into existing settings. Also trying to detect sentence endings within lines by .'s can be fraught with false positives.
If I understand correctly, yes your proposal would be helpful. Currently I need to carefully select each line a sentence is on. With your proposal, I could just select the entire paragraph, yes?
Yeah, so if you had the input on the left here and just pressed alt+q while the cursor was in that paragraph, you'd get the output on the right.

The only thing it doesn't do is "fix" the Short sentence. A sentence.... So it would be up to you to make sure that every sentence starts on a new line, but then that would be preserved.
Ah, I see. It's not perfect, but it would be very helpful. It's almost muscle memory for me now to hit Enter after finishing a sentence. Rewrapping becomes the most useful during the revising stage - As you can imagine, the length of lines change a lot during insert/delete/modify editing.
FYI Having all sentences reformatted (thing I said I probably wouldn't do) is looking more likely now it's also been requested in #301.
I'd also like an option to rewrap not based on column width, but by punctuation such that the result is one sentence/phrase per line.
This is what we suggest for writing in markdown with Manubot:
However, "one paragraph per line" makes the git diff less precise, leading to less granular review commenting, and makes conflicts more likely. Therefore, we recommend using semantic linefeeds — newlines between sentences. We have found that "one sentence per line" is preferable to "word wrap" or "one paragraph per line".
Would be nice to have this automated. When tracking prose with git, one sentence/phrase per line creates the cleanest diffs.
Semantic line-feeds reflow content so that single line-breaks follow punctuation, and double-line breaks signify paragraphs; this is also known as semantic line breaks. I wrote a plugin for Sublime Text that does this.