(defunxah-space-to-newline-2022-06-08 ()
"Replace space sequence to a newline char in current block or selection.
If `universal-argument' is called first, ask user to enter a character to replace.
URL `http://xahlee.info/emacs/emacs/emacs_space_to_newline.html'
Version: 2017-08-19 2021-11-28"
(interactive)
(let* (($bds (xah-get-bounds-of-block-or-region))
($p1 (car$bds))
($p2 (cdr$bds))
$charToLinebreak
)
(ifcurrent-prefix-arg
(setq$charToLinebreak
(read-string"Type a regex where you want linebreaks after:"))
(setq$charToLinebreak" "))
(save-restriction
(narrow-to-region$p1$p2)
(goto-char (point-min))
(while (search-forward$charToLinebreaknilt)
(replace-match (format"%s\n"$charToLinebreak))))))