Changing highlight line color in emacs

2020-05-17 04:17发布

问题:

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.

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.

回答1:

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)


回答2:

M-x customize-face RET hl-line will help you. Just pick a face you like (you can type the same command with the other theme installed, just to peek the values you like).