Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In emacs, can I have one set of line-wrap settings for code and one for text?

After quite a lot of experimentation, I think that I like:

(setq truncate-lines nil)
(setq word-wrap t)

for text editing, but

(setq truncate-lines t)
(setq word-wrap nil)

for programming.

In all modes, I like:

(setq fill-column 80)

so that I can use M-q and C-u M-q to flow text to 80 columns, but I also find that I dislike auto-fill mode and would never like it to be on.

I'm also not that keen on visual-line-mode (or at least the bit of it that isn't word-wrap)

Is there some incantation I can put in my .emacs file that will make me happy?

I define happy to be: 'it all just does what I want and I need never think about this again'.

like image 408
John Lawrence Aspden Avatar asked Apr 19 '12 19:04

John Lawrence Aspden


1 Answers

Use prog-mode-hook and text-mode-hook to set these variables:

(add-hook 'text-mode-hook '(lambda ()
    (setq truncate-lines nil
          word-wrap t)))

and

(add-hook 'prog-mode-hook '(lambda ()
    (setq truncate-lines t
          word-wrap nil)))
like image 88
Nicolas Dudebout Avatar answered Nov 15 '22 09:11

Nicolas Dudebout