vim colorschemes not changing background color

后端 未结 11 1935
北恋
北恋 2021-01-30 08:43

I try to apply various color schemes in vim that I have seen on the net. Whatever scheme I choose, the background remains white, even though screenshots of the applied scheme sh

11条回答
  •  悲&欢浪女
    2021-01-30 09:16

    I think the problem could be the way the default color is changed by the colorscheme. I've looked at some colorschemes that set default merely by:

    set background=light
    

    or

    set background=dark
    

    Not sure what limitations of those are. I don't think those work in terminals.

    In any case, you should be able to manually set background in a terminal by using the 'Normal' highlight. Insert it into a spot before most of the 'hi' commands in the colorscheme file and it should provide defaults they will work with. For example:

    hi Normal ctermbg=White ctermfg=Black guifg=Black guibg=White
    

    Change ctermfg (color terminal foreground) and ctermbg (color terminal background) to be whatever you want (or whatever color you were expecting to see in the colorscheme but now aren't seeing). (Remember, though, if the colorscheme already has a setting for hi Normal then this probably isn't your problem.)

    For ctermbg and ctermfg you can enter color names, but I think there is only a fairly limited number: Black DarkBlue DarkGreen DarkCyan DarkRed DarkMagenta Brown, DarkYellow LightGray, LightGrey, Gray, Grey DarkGray, DarkGrey Blue, LightBlue Green, LightGreen Cyan, LightCyan Red, LightRed Magenta, LightMagenta Yellow, LightYellow White

    Otherwise you should be able to use a number from 0 to 255 in place of the color name. Or this script gives rough idea, and lets you see how you could also set up to use more color names: Vim script with color settings

    Also, there are a number of scripts that help you use or convert colorschemes written for gui for use with cterm. E.g.,:

    Colorscheme support for cterm

    Does the overall settings for the terminal window have something to do with it?
    

    Maybe, but I'm pretty sure a properly written Vim colorscheme will override any terminal settings you've made. At least they do for me in Windows and on Ubuntu. . .

提交回复
热议问题