7

Whenever I open an org file, I have to activate auto-fill-mode and go through every signle line that I need to read and press RET to get a filled paragraph. Is there any way to globally set auto-fill-mode and applied to all the paragraphs in an org file while opening the file?

Best.

nima
  • 205
  • 2
  • 6

3 Answers3

7

If you want to globally set auto-fill-mode, as you say, the solution would be to put this in your .emacs.s/init.el (or equivalent):

(add-hook 'org-mode-hook 'turn-on-auto-fill)

This means that all files that are viewed in org-mode (usually, files ending in .org) will have auto-fill-mode switched on.

If you do that, you will only use @Tyler's answer once: To format the old paragraphs. After that, auto-fill-mode will keep adding RET as you type. You can use the occasional Meta-Q (fill-paragraph) to refill.

rleppink
  • 3
  • 2
dirkjot
  • 171
  • 1
  • 2
6

If you want a single org file that you share with others to get auto-filled put this as the first line:

# -*- eval: (auto-fill-mode 1) -*-

This will cause auto-fill minor mode to be used when the file is opened. This is part of a feature called 'local file variables'. It is often used to set tab width for code files. Emacs manual page on file variables

Brian C.
  • 181
  • 1
  • 4
3

If you want to fill all the lines in a region, use the command M-x fill-region. To mark the entire buffer (so the region includes the entire file), use the command M-x mark-whole-buffer, which is also bound to the keybinding C-x h.

If you only want to temporarily wrap the lines for easier reading, you can use visual-line-mode, combined with visual-fill-column (available as a package on MELPA) to visually wrap the lines without actually adding linebreaks to your file.

Tyler
  • 21,719
  • 1
  • 52
  • 92
  • Thanks, I did as you said and I still get line with an right-arrow on the edge of emacs windows which in case of clicking on it will scroll horizontally to the right showing the rest of the line and hiding the begining of the line. – nima May 23 '19 at 17:59
  • I want something like the normal emacs buffer which places curved arrows at the end of the line. – nima May 23 '19 at 18:02