Elisp: Reformat to Sentence Lines
This command breaks a long line or text block into multile lines, each line is a sentence, ending in a period.
This is useful for editing a thesis or long prose. Because it lets you clearly see the sentence structure.
(defun xah-reformat-to-sentence-lines () "Break a long line or text block into multiple lines by ending period. Work on text selection if there is one, else the current text block. URL `http://ergoemacs.org/emacs/elisp_reformat_to_sentence_lines.html' Version 2020-12-02 2021-04-14" (interactive) (let ($p1 $p2) (if (use-region-p) (setq $p1 (region-beginning) $p2 (region-end)) (progn (if (re-search-backward "\n[ \t]*\n+" nil "move") (progn (re-search-forward "\n[ \t]*\n+") (setq $p1 (point))) (setq $p1 (point))) (re-search-forward "\n[ \t]*\n" nil "move") (setq $p2 (point)))) (save-restriction (narrow-to-region $p1 $p2) (let ((fill-column most-positive-fixnum )) (fill-region (point-min) (point-max))) (goto-char (point-min)) (while (re-search-forward "\\. +\\([0-9A-Za-z]+\\)" nil "NOERROR") (replace-match ".\n\\1" )))))
The following are often useful together: