The LaTeX Layer by default wraps a line after column 85 by inserting a new line while typing and moving the current word to the new line. When the line is a comment, it even automatically inserts the comment prefix.

How can one disable this behaviour?

The emacs variables word-wrap and truncate-lines seem to have nothing to do with this, they only change how text is displayed while the above behaviour actually inserts new lines.

  • It's probably using auto-fill-mode. You can add a hook to latex-mode to disable it, or maybe there's some other way to configure that in spacemacs.
    – user12563
    Jun 27 '18 at 16:50
  • @DoMiNeLa10 Thanks, this seems to be the mode I was looking for.
    – user905686
    Jun 28 '18 at 16:43

The automatic wrapping is done by the minor mode auto-fill-mode (as hinted by DoMiNeLa10).

To disable it, add this to function dotspacemacs/user-config in .spacemacs:

(add-hook 'latex-mode-hook #'spacemacs/toggle-auto-fill-mode-off)

There is also the latex/auto-fill-mode, but that doesn't seem to be a mode itself (doc: "Toggle auto-fill-mode using the custom auto-fill function.").

See the layer documentation for auto-fill for fine-grained (latex specific) control of where auto-fill should be enabled.

  • 2
    While this worked at first, recently auto-fill-mode would be active again when loading latex mode, with the same settings. Now it works again (emacs 26.1, spacemacs 0.200.13 (didn't change), packages updated ~28.08.18).
    – user905686
    Aug 31 '18 at 15:01
  • Not working on spacemacs dev by the way.
    – tigerjack
    Mar 6 '19 at 18:14

As largely seen on the web, adding off-switch for the auto-fill minor mode to the (La)TeX major mode won't work anymore, not even with 'append. As duianto states, the solution has been properly documented in the auto-fill section of the LaTeX layer (in development).

Change LaTeX's layer line



(latex :variables latex-enable-auto-fill nil)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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