Set Color for selection region in Emacs

Posted on November 27, 2019

Usually in emacs when you select a region of text(activated by pressing C-SPC) the default color in which the text gets highlighted would be blue(in the default theme).

Oddly, for me I don’t see any color when I hightlight the text, and it is difficult without visual cue to know which part of the text got selected. So I had to manually set the color for hightlighted text when activating mark set. Run the following elisp code or add it to init.el

(set-face-attribute 'region nil :background "#666")

Doing this will change the highlight color.

Further to change the foreground color add :foreground "#colorcode to the previous elisp.

(set-face-attribute 'region nil :background "#666" :foreground "#ffffff")