7

I added the following settings to my dot-Emacs:

(add-hook 'org-mode-hook 'turn-on-auto-fill)
(add-hook 'org-mode-hook
        (lambda() (set-fill-column 80)))

When I'm typing sentences in an existing Org-file which are longer than 80 columns, it places on the next line in the Org-file. It works fine.

However, I have in the same Org-file already sentences that I typed in the past, which are longer than 80 columns.

How could I tell Emacs that he must format all sentences in the buffer which are longer than 80 columns. So that the existing words, which exceed 80 columns-limit will begin on the next line?

Stefan
  • 26,154
  • 3
  • 46
  • 84
ReneFroger
  • 3,855
  • 22
  • 63

1 Answers1

5

If you don't mind filling paragraphs rather than just individual sentences, the simplest way to do it is probably to select the entire buffer and use fill-region. Here's a simple command that will automate the process:

(defun fill-buffer ()
  (interactive)
  (save-excursion
    (save-restriction
      (widen)
      (fill-region (point-min) (point-max)))))
Dan
  • 32,584
  • 6
  • 98
  • 168
  • Simple, and such clever. Dan, you still manage to amaze me with such commands that I would spent many hours looking up and I could never worked out then. – ReneFroger Nov 15 '15 at 22:17
  • 1
    @ReneFroger: thanks. As you get more experience working with elisp, some of these things will become like second nature. Never stop learning! – Dan Nov 15 '15 at 22:23