Vim/Nvim: Background Opacity

14k views Asked by At

I know that you can make the background-color transparent in Vim but can you also reduce the opacity of a color?

I tried doing something like this but no success:

highlight Normal ctermbg=000000CC
highlight NonText ctermbg=000000CC
2

There are 2 answers

1
bk2204 On

This isn't possible in a terminal. The sequence to set a 24-bit color in the terminal provides values for red, green, and blue, but it doesn't provide an alpha channel. It may be that your terminal supports a custom escape sequence to set the opacity, but ncurses doesn't document any such sequence as standard. Even if your terminal does, that doesn't mean tmux or Vim can successfully invoke it.

What you can do is set your terminal to be transparent and then try not to set a background color, usually by setting the background color to NONE. Note that this is different than setting 0 as the background color, since that usually sets black as the background. For example, on my transparent terminal, running vim -u NONE causes Vim to draw a transparent background. That's the only option you have for something other than a completely opaque color.

0
dandcker On

To avoid this issue, a way is to set the terminal's background image to an image that you create yourself, after reducing its exposure. You also need to set vim's background to transparent, so you see the terminal's background image that you just set.