Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim/Nvim: Background Opacity

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
like image 927
emseidov Avatar asked Oct 23 '25 18:10

emseidov


2 Answers

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.

like image 126
bk2204 Avatar answered Oct 26 '25 08:10

bk2204


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.

like image 42
dandcker Avatar answered Oct 26 '25 10:10

dandcker