13

Is there an equivalent to the fill-column variable for the "Wrap" mode (visual-line-mode) in Emacs? If not, how could I set a limit on the length of visual lines when the window/frame of the buffer is wider ?

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Brian Z
  • 875
  • 1
  • 13
  • 20
  • It wasn't clear to me from reading the manual, but I just tried `M-x longlines-mode`, and so far it seems to do what I was looking for. – Brian Z Dec 23 '12 at 07:08
  • Oddly enough, it seems like the longlines-mode documentation is missing in more recent versions of the GNU Emacs Manual, but earlier versions have it. – aculich Dec 23 '12 at 11:03
  • 2
    For this I found the package [visual-fill-column](https://melpa.org/#/visual-fill-column) which I am very pleased with. Some answers mention longlines-mode having been removed. – ofthegoats Aug 06 '22 at 17:01
  • I use [olivetti](https://github.com/rnkn/olivetti) for this. You can also check out [writeroom](https://github.com/joostkremers/writeroom-mode) and [darkroom](https://github.com/joaotavora/darkroom). – mgalgs Aug 25 '22 at 18:39

2 Answers2

10

In response to this question I created a minor mode called window-margin that accomplishes what @Stefan suggested in his answer.

Turn on window-margin-mode with:

(add-hook 'text-mode-hook 'turn-on-window-margin-mode)

The way you can still do it without installing window-margin is to use the longlines-mode that ships with Emacs, but is being phased out since there are some problems with longlines-mode, but here's the old way to do it if you want:

Turn on longlines-mode with something like:

(add-hook 'text-mode-hook 'longlines-mode)

which wraps text at the fill-column.

Community
  • 1
  • 1
aculich
  • 14,545
  • 9
  • 64
  • 71
  • 1
    Thank you so much for this useful replacement to `longlines-mode`! I have a couple of minor feature requests, I will add them as issues on GitHub. – Brian Z Dec 28 '12 at 03:21
  • yes, please do request features! there are some other features that i'd also like to implement, as well as fixing a few inevitable quirks that i've already been annoyed by and want to tweak, so your feedback will be helpful. – aculich Dec 28 '12 at 04:05
3

longlines-mode has been removed. For visual-line-mode, the simplest way is to make the window as narrow as you want it to be. You can do that with C-x 3 and then adjusting the size of the window. Or you can set a wide margin or wide fringes.

Stefan
  • 27,908
  • 4
  • 53
  • 82
  • I tried `C-x 2` before, but that's not a solution, at least not without a bit of tweaking. For this to work, the new window should have a blank buffer and should be on the right, but that's not what's happening for me. So I am happier with `longlines-mode` for now. – Brian Z Dec 24 '12 at 17:21
  • @Stefan, you're right that adjusting window size and or margins is the right way to go, but there's no easy and automatic way to do that... until now since I just [wrote a minor mode](https://github.com/aculich/window-margin.el) to do it. – aculich Dec 26 '12 at 07:50
  • 1
    Just to clarify, Stefan probably meant `C-x 3` instead of `C-x 2` – Marius Hofert May 19 '13 at 14:22
  • What window? I'm in console mode. – August Karlstrom Mar 07 '14 at 11:57
  • 3
    "window" in the Emacs sense (not the GUI sense), so they exist in tty frames just as much as in GUI frames. I.e. you can use `C-x {` and `C-x }` to resize the window after `C-x 3`, or better use the `windresize` package which should hopefully become standard in Emacs-24.5. – Stefan Mar 07 '14 at 18:33