I'd like to map a button to toggle Vim's background between transparent (to see stuff on other apps) and dark.
My current settings
I'm using onedark theme. There's currently no other background setting.
(Part of) my
set encoding=utf-8 set nocompatible set rnu nu set wildmode=longest,list,full set wildmenu filetype plugin on syntax on " Theme colorscheme onedark " Toggle transparent background let t:is_transparent = 0 function! Toggle_transparent() if t:is_transparent == 0 hi Normal guibg=NONE ctermbg=NONE let t:is_transparent = 1 else set background=dark let t:is_tranparent = 0 endif endfunction nnoremap <F1> : call Toggle_transparent()<CR>
Stuff I've tried
:hi Normal guibg=NONE ctermbg=NONE didn't work.
I found this script (I've added it to my
vimrc) which also doesn't make my background transparent and the toggling seems to fail after the first couple of toggles:
let t:is_transparent = 0 25 function! Toggle_transparent() 26 if t:is_transparent == 0 27 hi Normal guibg=NONE ctermbg=NONE 28 let t:is_transparent = 1 29 else 30 set background=dark 31 let t:is_tranparent = 0 32 endif 33 endfunction 34 nnoremap <F1> : call Toggle_transparent()<CR>
What's wrong with
hi Normal guibg=NONE ctermbg=NONE? How can I actually make
- I'm using Manjaro KDE
- I have
- Transparency works fine in the terminal
guibg=NONE ctermbg=NONEquite work? What do you see that's unexpected? Are you using gvim or terminal? Which OS/Desktop Environment? Which Terminal? Does transparency work in your terminal while you're using the shell? These would be useful in figuring out what could fix this for you...