I want to have Spacemacs wrap around long lines, but only in text files (i.e. text mode), not in programming language files (i.e. program mode).

How could one achieve that? I know that to turn on line-wrapping one could simply include this in the user-config:

(setq toggle-word-wrap)

To turn it on only for text files, I tried:

(add-hook 'text-mode-hook 'toggle-word-wrap)

But it did not work. How could I implement that?

1 Answer 1


Put this in your dotspacemacs/user-config:

(defun my/enable-word-wrap ()
  (setq-local word-wrap t))
(add-hook 'text-mode-hook #'my/enable-word-wrap)

That works for me, for example, if I open a new file with SPC f f and then SPC SPC text-mode.

toggle-word-wrap is an interactive command (not merely a non-interactive function) that does as it says: toggles word wrap, not really ideal for programmatic use.

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.