The CursorLine highlighting group defines how the current line will be highlighted, once :set cursorline
is enabled. As you have noticed, it contains an option for setting the background color.
If you do not want that and basically just want the underlining to take place, I would suggest to change the highlighting group to:
:hi CursorLine cterm=underline term=underline ctermbg=NONE guibg=NONE
This will set the background color for the gui and the terminal to be transparent (e.g. use the color that is defined by the corresponding syntax highlighting group).
The CursorLine highlighting group is usually set whenever you source a color scheme. To overwrite your custom CursorLine setting, you can use the ColorScheme
autocommand like this:
:au Colorscheme * :hi CursorLine cterm=underline term=underline ctermbg=NONE guibg=NONE
This will make sure, the CursorLine highlighting will always be redefined even if a color scheme has set it differently.
:hi Cursorline
? – Christian Brabandt Dec 18 '18 at 8:39CursorLine xxx term=underline cterm=underline guibg=Grey40
– Bananach Dec 18 '18 at 9:05