Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Have emacs highlight characters over 80? [duplicate]

Tags:

emacs

I have seen some solutions on here which will highlight an entire line if it goes beyond 80 characters, and also to do a line-wrap once the line becomes greater than 80. What I would like to do is to edit my .emacs file so that any character beyond 80 takes on a different background. So the first 80 characters will have my current emacs background, then characters > 80 would have a black background say. Can someone point me in the right directions? Thanks!

like image 884
Houdini Avatar asked Sep 17 '13 16:09

Houdini


2 Answers

I recently wrote an extensive article on the subject. Here's the gist of it:

(require 'whitespace)
(setq whitespace-line-column 80) ;; limit line length
(setq whitespace-style '(face lines-tail))

(add-hook 'prog-mode-hook 'whitespace-mode)
like image 57
Bozhidar Batsov Avatar answered Nov 13 '22 15:11

Bozhidar Batsov


Here are some other solutions that people use, in addition to the one that @BozhidarBatsov mentions:

  • Library column-marker.el -- highlight any column(s)
  • Library fill-column-indicator.el -- highlight the fill column
  • Library mode-line-posn.el -- highlight column number in mode line when greater than limit
  • Library wide-column.el -- highlight cursor when column passes limit

See also:

  • FindLongLines
  • HighlightLongLines
  • EightyColumnRule
  • MarginMode

(FWIW, my personal preference is mode-line-posn.el --- less intrusive, just the right amount of indication.)

like image 7
Drew Avatar answered Nov 13 '22 16:11

Drew