15

I have found some color schemes that I like, but some of them have the feature that the lines below the content of the file on the display - the ~ area - have a different background color as shown.. I want it to be the same background color as normal text. When editing the color scheme, what keyword am I looking for to fix this?

I'm using MacVim but I assume this is a universal question.

Two different backgrounds

2 Answers 2

17

Since Vim 8 there is the EndOfBuffer highlight group for this; from :help hl-EndOfBuffer:

EndOfBuffer filler lines (~) after the last line in the buffer.
        By default, this is highlighted like hl-NonText.

For earlier Vim versions it's NonText. From :help hl-NonText:

NonText         '~' and '@' at the end of the window, characters from
                'showbreak' and other characters that do not really exist in
                the text (e.g., ">" displayed when a double-wide character
                doesn't fit at the end of the line).

I didn't know this either. How I found this:

  • I typed :help 'highlight'
  • I noticed there's a list with highlight "occasions" here with a brief description.
  • Type /\~ to search for the ~ character

And on :help colorscheme I read:

:hi[ghlight] clear {group-name}
:hi[ghlight] {group-name} NONE
                        Disable the highlighting for one highlight group.  It
                        is _not_ set back to the default colors.

Using :highlight clear NonText seems to work for me.

0
3

In terms of highlight groups, I believe it is called NonText. From :he highlight-groups:

                                                        hl-NonText
NonText         '~' and '@' at the end of the window, characters from
                'showbreak' and other characters that do not really exist in
                the text (e.g., ">" displayed when a double-wide character
                doesn't fit at the end of the line).

You can probably set it to the same colour as the remaining area using:

:hi NonText ctermfg=NONE
6
  • Thanks for the answer. NonText was what I needed. I found the snippet didn't work, though hi NonText ctermbg=NONE did as per @Carpetsmoker's answer.
    – Coljac
    Apr 28, 2015 at 12:27
  • @Coljac I'm confused. Isn't that exactly what I have written?
    – muru
    Apr 28, 2015 at 12:43
  • Apologies for the cut and paste error. It was :highlight clear NonText that worked (from vim) - though knowing "NonText" I was able to edit the colorscheme easily enough.
    – Coljac
    Apr 28, 2015 at 12:50
  • @Coljac Muru's example had a minor typo: it was ctermbg, but should be ctermfg (I've fixed this now). Apr 28, 2015 at 12:52
  • @Carpetsmoker if that works, colour me surprised. I thought fg applied to the text.
    – muru
    Apr 28, 2015 at 12:55

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.