Highlight one line in a longer line

When using word wrapping in emacs, long lines can be wrapped in shorter lines. The insufficient hl-line mode seems to highlight the entire wrapped line.

I would like to highlight only one highlighted line that the cursor is currently on. In the screenshot, this will be the first line.

Screenshot

Which setting do I need to change?

+3


source to share


1 answer


The mode hl-line

allows you to set a custom line definition function in the hl-line-range function. This feature allows you to decide where the line starts and where it ends. Just set it to something suitable:

(defun visual-line-range ()
  (save-excursion
    (cons
     (progn (beginning-of-visual-line) (point))
     (progn (end-of-visual-line) (point)))))

(setq hl-line-range-function 'visual-line-range)

      



Voila.

+1


source







All Articles