0

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

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

1 Answer 1

1

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.

7
  • 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
    Commented Dec 18, 2018 at 10:27
  • then I don't understand what is wrong with your second picture. Commented Dec 18, 2018 at 10:32
  • you mean what I don't like about it or why it is like it is?
    – Bananach
    Commented Dec 18, 2018 at 10:35
  • I mean what your problem is Commented Dec 18, 2018 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 Commented Dec 18, 2018 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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