Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make emacs highlight lines that go over 80 chars?

Tags:

emacs

I know there are solutions to making emacs show the 80 line column, but I don't want that sort of visual disturbance. I'd just like to make it highlight a line if it's over 80 characters.

like image 412
alexgolec Avatar asked Jun 14 '11 13:06

alexgolec


4 Answers

Another easy option is to run highlight-lines-matching-regexp on the expression .\{81\}.

Every line with 81 characters or more will be highlighted with the color of your choice.

like image 115
Juancho Avatar answered Sep 25 '22 18:09

Juancho


See whitespace-mode -- it's now part of Emacs, and can do much more than highlighting just long lines. (But of course can be used to do only that.)

like image 45
Eli Barzilay Avatar answered Sep 23 '22 18:09

Eli Barzilay


Here's my config from Emacs Dev Kit:

;; whitespace-mode
;; free of trailing whitespace and to use 80-column width, standard indentation
(setq whitespace-style '(trailing lines space-before-tab
                                  indentation space-after-tab)
      whitespace-line-column 80)

Basically you need just the last bit, but I find the other settings quite useful (I hate tabs and trailing whitespaces).

like image 7
Bozhidar Batsov Avatar answered Sep 25 '22 18:09

Bozhidar Batsov


Try highlight-80+.el. You can acquire it from here.

To install it, just add the following to your .emacs:

(add-to-list 'load-path "/path/to/highlight-80+")
(require 'highlight-80+)

You can then enable it via:

M-x highlight-80+-mode

like image 5
ClvrObj Avatar answered Sep 24 '22 18:09

ClvrObj