How can I make emacs highlight lines that go over 80 chars?
Solution 1:
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.
Solution 2:
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.)
Solution 3:
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).
Solution 4:
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
Solution 5:
Here is some example code which will highlight text that lies beyond column 80 with the current 'warning' face, and a line to enable it for C++ mode.
;; Turn on warn highlighting for characters outside of the 'width' char limit
(defun font-lock-width-keyword (width)
"Return a font-lock style keyword for a string beyond width WIDTH
that uses 'font-lock-warning-face'."
`((,(format "^%s\\(.+\\)" (make-string width ?.))
(1 font-lock-warning-face t))))
(font-lock-add-keywords 'c++-mode (font-lock-width-keyword 80))
It doesn't highlight the whole line, but I find it is reasonably helpful.