Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Emacs 23 in a Debian GNU/Linux variant distribution. In a default Emacs session launched with emacs -q (to confirm the settings) I execute the following to setup the environment I would like:

 M-x toggle-truncate-lines <RET>
 M-x set-variable word-wrap t <RET>

I leave visual-line-mode set to whatever it's default is.

I would like to place these settings into my ~/.emacs file so that they are always active. I did this with the following:

(setq word-wrap t)
(setq-default truncate-lines nil)
(setq visual-line-mode nil)

However, these settings do not replicate the environment I would like. Long lines are not wrapped -- they extend beyond the right edge. If I then run M-x toggle-truncate-lines they wrap as I want, but not on word boundaries, so the word-wrap setting has also not taken effect. I also tried setting truncate-lines in ~/.emacs to t, but this made no difference. The documentation for truncate-lines reads as follows, so setting this variable to nil appears to be what I am looking for:

*Non-nil means do not display continuation lines.
Instead, give each line of text just one screen line.

I have not split any windows horizontally, so truncate-partial-width-windows does not apply.

How do I setup the environment I would like in ~/.emacs?

share|improve this question

if toggle-truncate-lines is given a negative argument, it allways switches truncating off.


(setq-default word-wrap t)
(toggle-truncate-lines -1)
share|improve this answer

If you simply want to replicate the behavior of the function call toggle-truncate-lines, why not just do:


in your ~/.emacs file?

Of course, you can also put (setq word-wrap t) in there too, though I suspect you should do (setq-default word-wrap t), since variable word-wrap becomes buffer-local when set in any way.

share|improve this answer
I have (toggle-truncate-lines) and (setq-default word-wrap t) in my ~/.emacs file. The word-wrap appears to be working. However, long lines extend beyond the right edge regardless of whether I have (toggle-truncate-lines) in my ~/.emacs or not. Truncating long lines is buffer-local I think? Maybe that's why including it in ~/.emacs is not having an effect. That's why I also tried (see question) to set (truncate-lines), which also didn't work. – SabreWolfy May 31 '12 at 5:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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