Seeking how could add two spaces after each line on a given text buffer in EMACS.
This is a way for add LINE BREAKS on EMACS export via org-mode.
First off, make sure you (or some package you've installed) haven't added
delete-trailing-whitespace on a hook. It's not on any hooks by default, but it's fairly common to add it to
Quick and dirty:
C-M-< C-M-% $ RET SPACE SPACE RET !. This will go to the beginning of the buffer (
C-M-%), replacing end of line (
$) with two spaces, and applying it to the every match (
RET means press the return key and
SPACE means press the space bar. Replace
[^ ][^ ]$ and
SPACE SPACE with
\& SPACE SPACE to only work on lines that end in less than two spaces (this will also make the operation idempotent).
\& means the entire matched string (in this case, the last two characters).
(defun ensure-trailing-spaces () "Ensure there are two spaces at the end of every line." (interactive "*") (save-excursion (goto-char (point-min)) (while (not (eobp)) (end-of-line) (unless (looking-back " $") (insert " ")) (forward-line))))
Note that this unconditionally inserts two spaces at the end of every line, even if there is already one space, thus there will either be two or three spaces at the end of every line.