enter image description here

I expected the folded text highlighted as below picture (ignore red rectangle): enter image description here

Like the above picture, I'd like to have something to recognize that red region of a fold and highlight it only, do not have ctermbg apply to the region of the redundant space.

This question is kind of general, I don't have much experience so I try to explain from the user's perspective, I'd like to have that red region highlighted only that is a folded block of text.

  • can you show us picture as it is and another one as it should be?
    – Maxim Kim
    Commented Nov 6, 2018 at 13:10
  • @MaximKim: I've just update the picture of expected folded text. Don't count the red rectangle. Commented Nov 6, 2018 at 13:19
  • Ok, it is clear now. I don't think it is possible though.
    – Maxim Kim
    Commented Nov 6, 2018 at 13:25

1 Answer 1


That is not possible.

The folded text always uses the highlighting group Folded for the complete screen line.

However, you can of course change the highlighting group so that it doesn't stand out so much.

For example remove the background attribute of the Folded group to make only the text standout (or you could use a background attribute that doesn't have such a big contrast to the Normal highlighting group:

hi Folded ctermfg=102 guifg=#878787 guibg=NONE ctermbg=NONE

Note, that this might make it hard to realize that this is actually folded text as can be seen here:enter image description here

  • Is there a way to check if it's folded or not and then matchgroup against it and use custom highlight? Remove ctermbg is not the way because I need it highlighted. Commented Nov 6, 2018 at 16:28
  • sorry, I don't understand what you like to do Commented Nov 6, 2018 at 16:28
  • I only need remove ctermbg on redundant spaces but keep on the text. Commented Nov 6, 2018 at 16:29
  • @TuyenPham as I said at the beginning of my answer, that is not possible Commented Nov 7, 2018 at 6:26
  • 1
    there are various functions to be used for checking if a line is folded or not, see :h function-list. However, that won't let you do what you want. The highlighting group is global, once you change it, it will take effect for all windows, buffers and all characters in each fold Commented Nov 7, 2018 at 6:38

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.