visual-line-mode is very useful to wrap lines with the window size changing without inserting any newlines. But in org-mode, it also wraps the headline and source blocks which is a little bit annoying.

So here comes my question: How can I turn off visual-line-mode for org-heading and source blocks permanently in org-mode?

  • If it is possible to both wrap (setq word-wrap t) and truncate (setq truncate-lines t) different portions of the same buffer, I'll definitely make this thread one of my favorites! – lawlist Jan 16 '15 at 7:14
  • @lawlist So you mean it is impossible to make it in org-mode? – Leu_Grady Jan 16 '15 at 7:15
  • 2
    Lol, you are a expert on emacs in my mind, lol. Okay, let's expect solvable answers! – Leu_Grady Jan 16 '15 at 7:23
  • 1
    Here is an idea that I use, but it is not what you had in mind. I have the default in the buffer as being (setq truncate-lines t) and (setq word-wrap nil). When I edit any entry or if I just want to zoom-in/focus on one entry in particular, I have it set to narrow to subtree, at which time it wraps with visual-line-mode -- aka (setq word-wrap t) and (setq truncate-lines nil). When I finish editing, it widens and goes back to truncated lines. – lawlist Jan 16 '15 at 7:24
  • 2
    I'm pretty sure there is no way to inhibit word wrap for some regions only, e.g. via text properties. Report it as bug. Of course, one might rationalize that code lines shouldn't be that long in the first place. As for headlines (and lists), `org-indent-mode' looks pretty nice. – olaf b Mar 13 '15 at 19:05

Another solution is to use adaptive-wrap-prefix-mode.

This way you'll see the full header and source but it will wrap nicely indented.

With visual-line-mode:

enter image description here

With visual-line-mode and adaptive-wrap-prefix-mode:

enter image description here

| improve this answer | |

This is a good question! The same issue applies when you have an Org table that is wider than fill-column. What I do is open the section in an indirect buffer with org-tree-to-indirect-buffer i.e. C-c C-x b. And in the indirect buffer, I disable visual-line-mode for editing that section.

| improve this answer | |
  • This pin-points also my major problem with adaptive-wrap-prefix-mode. Pityingly the solution is cumbersome. But, that is not your fault. – Tobias Mar 9 '18 at 8:38
  • @Tobias I made a new command that narrow the table while turning on truncate-lines, then you can enjoy the unwrapped table, which is pretty nice. – Leu_Grady Sep 10 at 9:44

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.