29

When Vim starts, it displays the tilde symbol (~) for empty lines. Is there a way to change its color?

ib.
  • 27,830
  • 11
  • 80
  • 100
grigoryvp
  • 40,413
  • 64
  • 174
  • 277
  • Related if not the same: https://stackoverflow.com/questions/3813059/is-it-possible-to-not-display-a-for-blank-lines-in-vim – jdhao Oct 31 '20 at 07:35
  • Also related (and also not the same): https://stackoverflow.com/q/3725526/254635 – ib. Jan 30 '21 at 08:10

7 Answers7

36

Try this:

:highlight NonText ctermfg=12

12 is the default color; change as you see fit.

Lucas Oman
  • 15,597
  • 2
  • 44
  • 45
17

In Vim 8, you can set the EndOfBuffer highlight group separately from NonText:

highlight EndOfBuffer ctermfg=bg
fvgs
  • 21,412
  • 9
  • 33
  • 48
Neal Fultz
  • 9,282
  • 1
  • 39
  • 60
  • `:help E420`: "This only works after setting the colors for the Normal group and for the MS-DOS console." – Neal Fultz Sep 20 '20 at 22:02
  • can you link to any site that teach me how to set the color? sry, im new to vim – slier Sep 21 '20 at 14:50
  • Is it possible to completely deactivate the displaying of the tildes? Setting the color to the same as the background color of vim is a first step in the right direction, does not solve the problem for a transparent terminal though. Even with `highlight EndOfBuffer ctermfg=none`, they are still shown. – pfincent Jan 03 '23 at 17:45
  • I posted a new answer about changing the fill character itself, instead of the color. – Neal Fultz Jan 03 '23 at 21:57
8

Lucas is right but if you want to change the colour in gvim as well I think you need guifg= as well as ctermfg=

i.e. :highlight NonText ctermfg=*color* guifg=*color*

mikej
  • 65,295
  • 17
  • 152
  • 131
8

I can't leave comments yet, so this will have to be an answer..

Lucas is correct, but you must remember that this will also change the color of the characters shown when you :set list. If you are attempting to hide these tildes, you will also hide those characters.

Randy Morris
  • 39,631
  • 8
  • 69
  • 76
2

For standard Vim 8.x, the following works:

:highlight EndOfBuffer ctermfg=*color*

This colors tildes at the end of buffers into a specifically determined color.

For gVim 8.x, the following is smoother:

:highlight EndOfBuffer guifg=bg

This is better since it colors tildes at the end of buffers into the color of the background, effectively making such tildes transparent.

Paul Kim
  • 1,153
  • 1
  • 9
  • 17
1

Newer versions of neovim let you override the fillchar and has a bit of special casing if you make it a space.

set fcs=eob:\ 

^^^ There is an escaped space at the end

YMMV with vim or with older versions.

Neal Fultz
  • 9,282
  • 1
  • 39
  • 60
-1

You could try a new color scheme.

:colors <colorscheme name>

You can find the names of the schemes installed on your system in $VIMRUNTIME/colors/ Also, if the 'bg' option isn't set properly, those little tildes can be hard to see.

Steve K
  • 2,124
  • 16
  • 19