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

后端 未结 8 1521
不思量自难忘°
不思量自难忘° 2020-12-01 02:18

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 ov

相关标签:
8条回答
  • 2020-12-01 02:41

    There is a built-in package in emacs-goodies-el(recommend to install it in terminal) called highlight-beyond-fill-column.el, add this to your .emacs or init.el:

    (setq-default fill-column 80)
    (add-hook 'prog-mode-hook 'highlight-beyond-fill-column)
    (custom-set-faces '(highlight-beyond-fill-column-face
                        ((t (:foreground "red" )))))
    

    The text beyond fill-column which is 80 in the snippet will be highlighted with the color of red. You can set the face as you like.

    0 讨论(0)
  • 2020-12-01 02:45

    This is not exactly what you wanted, but I had a similar problem and found this question/answer. All I wanted was to insert a visual guide, when I needed it. This is what I finally ended up with:

    (defun insert-80 ()
        "Insert an 80-character-wide guide at beginning of line."
        (interactive)
        (beginning-of-line)
        (insert "0         1         2         3         4         5         6         7         |")
        (newline)
        (insert "01234567890123456789012345678901234567890123456789012345678901234567890123456789|")
        (newline)
    )
    

    Super simple, but sometimes very effective.

    0 讨论(0)
提交回复
热议问题