Skip to content

Instantly share code, notes, and snippets.

@ychaouche
Last active July 24, 2025 15:02
Show Gist options
  • Save ychaouche/3fd8e329a4e155df8f154446d92ebc22 to your computer and use it in GitHub Desktop.
Save ychaouche/3fd8e329a4e155df8f154446d92ebc22 to your computer and use it in GitHub Desktop.
add-newline-after-punctuation.el
(defun add-newline-after-punctuation9 (start end)
"Place a newline after each sequence of 4 or more words followed by a comma, semicolon, colon, or period in the region."
(interactive "r")
(save-excursion
(goto-char start)
(while (re-search-forward "\\(\\w+\s+\\)\\{3,\\}\\w+\s*[.,:;])" end t)
(replace-match "\\&\n"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment