1

I use org files to write prose and I want to have line-wrapping enabled in those files by default. If possible, I don't want to enable it for all org files, just those used specifically for prose. Is there an org header-arg or command that could make this happen?

1 Answer 1

2

You can put the following snippet at the end of your org file:

* Local Variables                                       :noexport:
# Local Variables:
# eval: (visual-line-mode 1)
# End:

Here is some documentation


Visual line mode does not modify the buffer, it only modifies how it is displayed. If the window is narrower than a (logical) line, the line is displayed as a number of screen lines. How many depends on the width of the window and if the window width changes, the display of the line changes accordingly.

An alternative is auto-fill-mode where a line is split at an appropriate place as you type. This changes the buffer, so widening the window is not going to change the appearance.

The mechanism is the same as for visual-line-mode: a local variable block:

* COMMENT Local variables                               :noexport:
# Local Variables:
# eval: (auto-fill-mode 1)
# fill-column: 78
# End:

See Auto-fill mode in the Emacs manual and the doc string of fill-column with C-h v fill-column. Note that the setting of fill-column is buffer-local, so you can have different values in different files,

5
  • What if the OP prefers conventional line wrapping (say at column 78) rather than visual line mode? You probably should also mark the section with a COMMENT keyword or a :noexport: tag (or both) so that Org mode ignores it in most contexts.
    – NickD
    May 21, 2023 at 19:16
  • 1
    @NickD, I did put a :noexport: tag. How do you do conventional line wrapping?
    – crocefisso
    May 22, 2023 at 0:27
  • See the edited answer.
    – NickD
    May 22, 2023 at 2:13
  • Very interesting, thank you @NickD.
    – crocefisso
    May 22, 2023 at 10:09
  • Thank you, this solved my problem. May 22, 2023 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.