7

Almost every text editor is able to truncate lines by default, but in Emacs I'm still using the cumbersome M-x toggle-truncate-lines in every buffer with long lines. Unfortunately, buffers with long lines are very common, so one has to do M-x toggle-truncate-lines constantly.

Solutions currently posted on StackOverflow do not work (e.g., link):

  • (setq-default truncate-lines t) in init.el does not have any effect.
  • (custom-set-variables '(truncate-lines t)) in init.el does not have any effect.
  • (global-set-key "\C-x\ w" 'toggle-truncate-lines) does not really solve the problem.

I must be overlooking something here; what's the actual setting for truncating long lines by default?

Wouter Beek
  • 289
  • 3
  • 14

1 Answers1

7

truncate-lines possibly overridden

The built-in help for truncate-lines mention that it is overridden by the variable truncate-partial-width-windows. You might want to check if it is set by using <C-h> v and typing truncate-partial-width-windows.

Relevant portion of built-in help for truncate-lines

...
Note that this is overridden by the variable
`truncate-partial-width-windows' if that variable is non-nil
and this buffer is not full-frame width.
...
yongjieyongjie
  • 286
  • 1
  • 5
  • (global-visual-line-mode) works as expected. https://stackoverflow.com/questions/950340/how-do-you-activate-line-wrapping-in-emacs/950406#950406 – Jiacai Liu Feb 08 '20 at 01:18
  • @JiacaiLiu, it does, if you expect something else than _scrolling_, which is what the OP is actually after (referring to the default behavior of "almost every text editor" :) ). "Truncating lines" and its relation to horizontal scrolling seems to be yet another arcane emacs (mis)feature to turn a common and trivial thing into something properly confusing and frustrating. ;) – Sz. Aug 24 '23 at 22:54