linuxemacsthemescustomizationemacs-prelude

Changing highlight line color in emacs


I installed emacs 24 and also installed prelude and I wanted to change the theme from zenburn to tango-dark. But the color that the line is highlighted is yellow and I don't like that. I want it to be like the gray color in zenburn. tango-dark theme with hl-line enabled(yellow)

zenburn theme with hl-line enabled(dark gray)

What should I do? I prefer not to turn off the hl-line but when I tried that I saw that the space between parentheses () are highlighted with the same yellow color. (In zenburn theme that didn't happen). I also know that this is not part of the tango theme because when I run vanilla emacs(sudo emacs) with tango theme no such highlighting happens. tango-dark theme with hl-mode disabled vanilla emacs with tango-dark theme


Solution

  • That would be an easy fix if you customize your init file (~/.emacs, ~/.emacs.el, or ~/.emacs.d/init.el)

    Turn on hl-line:

    (global-hl-line-mode 1)
    

    Set any color as the background face of the current line:

    (set-face-background 'hl-line "#3e4446")
    

    To keep syntax highlighting in the current line:

    (set-face-foreground 'highlight nil)