Search code examples
vimcolorscolor-scheme

how to get the background color in vim?


Is it possible to get the background color of the current color scheme in vim?

I tried :hi Normal but the response isn't helpful: Normal xxx cleared


Solution

  • If there's a way, it's through :hi Normal (or rather :echo synIDattr(hlID("Normal"), "bg"), which avoids the need to capture the command output); I don't know about any other means, e.g. a dedicated getbgcolor() function. For me, this works fine (in Windows GVIM):

    Normal         xxx guibg=#FFFBF0 font=Courier:h10:cANSI
    

    If the guibg attribute doesn't appear, I guess that means that the (operating system's) default background color is used; i.e. nothing has been set.