I'm using emacs 25.1.1 with the prelude config. In Atom I used to have a setting that made my lines wrap at 80 characters (without cutting words) for better readability. I've searched on the web for something similar for emacs but I have not found anything. Any ideas on how to do this?

  • 1
    See command auto-fill-mode and variable fill-column. – Drew Jan 26 '17 at 14:59

auto-fill-mode is what you're looking for. You can enable it automatically for editing text by adding this to your config:

(add-hook 'text-mode-hook #'auto-fill-mode)

You can customize how long lines in your text documents should be by customizing the fill-column variable. For example:

(setq-default fill-column 80)

If you want to to make sure that lines don't split on your screen as you're typing things, you can set up visual line mode.

To enable this for code files add:

(add-hook 'prog-mode-hook #'auto-fill-mode)
  • 1
    Added those two lines to my config but it doesn't seem to do anything. Lines still continue beyond 80 characters... – José María Jan 26 '17 at 11:11
  • The examples that I have provided will work only for editing text files, not code. Also, lines get wrapped when you type space or other character that doesn't belong it a word. I don't know how well auto-fill-mode would work for editing code. – user12563 Jan 26 '17 at 11:21
  • Um, hm. And for editing code there is nothing like that? And what about org-mode? – José María Jan 26 '17 at 11:24
  • 1
    Doesn't seem to... Added that but lines still extend beyond the screen bounds. – José María Jan 26 '17 at 11:32
  • 1
    That last thing worked beautifully! I also used this melpa.org/#/visual-fill-column to adjust it to the column width. Thanks! – José María Jan 26 '17 at 12:06

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.