If I use set cursorline, then lines that have some background color set (like in quickfix windows in vimtex) lose that color.

How can I prevent that?

For example: In the first picture, the cursor is on the second line of the quickfix window. Then I press k to go to the first line and the yellow highlighting disappears.

enter image description here

enter image description here

  • can you post a screenshot please? – Christian Brabandt Dec 18 '18 at 7:48
  • @ChristianBrabandt Done – Bananach Dec 18 '18 at 8:22
  • what is the output of :hi Cursorline? – Christian Brabandt Dec 18 '18 at 8:39
  • @ChristianBrabandt CursorLine xxx term=underline cterm=underline guibg=Grey40 – Bananach Dec 18 '18 at 9:05

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.

  • I executed both commands from your answer in my example and it didn't help. hi: CursorLine gives CursorLine xxx term=underline cterm=underline while I still see the second picture from my question – Bananach Dec 18 '18 at 10:27
  • then I don't understand what is wrong with your second picture. – Christian Brabandt Dec 18 '18 at 10:32
  • you mean what I don't like about it or why it is like it is? – Bananach Dec 18 '18 at 10:35
  • I mean what your problem is – Christian Brabandt Dec 18 '18 at 10:47
  • 1
    Ah, I see. Looks like it is impossible, as one does not know the current quickfix item and it doesn't come from the syntax rules. So the CursorLine highlihgting overwrites it – Christian Brabandt Dec 18 '18 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.