1

Is there in Emacs an inbuilt function to separate text into sentences?

Eg.,

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

into

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

2
  • 1
    Do C-h f -sentence TAB and see what functions are available. The common convention is that a sentence is terminated by a period, question mark, exclamation mark, with two spaces following.
    – NickD
    Mar 22, 2022 at 19:05
  • 1
    Note that "separate text into sentences" is not possible in practice unless sentence-end-double-space is adhered to in the source text, or the source text is not arbitrary text (which might contain confusable . character usage).
    – phils
    Mar 23, 2022 at 2:45

1 Answer 1

1

There's no predefined function to do that. You can easily define one.

Or just use a keyboard macro. Use M-e (forward-sentence) to advance past the sentence end. Then use M-x forward-whitespace to advance past any whitespace. Then use C-q C-j C-q C-j to insert two newline characters.

C-x (
M-e
M-x forward-whitespace
C-q C-j C-q C-j
C-x )

Execute the keyboard macro using C-x e. Use C-u 9999 to run it 9999 times successively.


You can also convert the keyboard macro to a Lisp command, or code that by hand using forward-sentence, forward-whitespace, and (insert "\n\n").

3
  • M-e actually moves the cursor to the end of the paragraph, it won't stop after a full stop (point). Haven't found such function yet (to move to the end of a sentence). Mar 23, 2022 at 8:00
  • Is your M-e bound to forward-sentence? And you can test whether it takes point to the beginning of a paragraph, and if so back it up.
    – Drew
    Mar 23, 2022 at 14:45
  • It's bound to both org-forrward-sentence and forward-sentence Mar 23, 2022 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.