Setting the Vim background colors

﹥>﹥吖頭↗ 提交于 2019-11-27 05:02:30

问题


When I try to change the background colors in .vimrc or directly in Vim using the command:

set background=dark

... it doesn't affect my background at all. Neither does the light option. However, it looks okay when I run gvim.

Is there a way to change the background in Mim without changing my Konsole settings?

EDIT Okay, there is a difference between guifg/guibg and ctermfg/ctermbg. While the GUI accepts lots of different color combinations, cterm allows only few standard ones.


回答1:


As vim's own help on set background says, "Setting this option does not change the background color, it tells Vim what the background color looks like. For changing the background color, see |:hi-normal|."

For example

:highlight Normal ctermfg=grey ctermbg=darkblue

will write in white on blue on your color terminal.




回答2:


In a terminal emulator like konsole or gnome-terminal, you should to set a 256 color setting for vim.

:set  t_Co=256

After that you can to change your background.




回答3:


Try adding

set background=dark

to your .gvimrc too. This work well for me.




回答4:


Using set bg=dark with a white background can produce nearly unreadable text in some syntax highlighting schemes. Instead, you can change the overall colorscheme to something that looks good in your terminal. The colorscheme file should set the background attribute for you appropriately. Also, for more information see:

:h color


来源:https://stackoverflow.com/questions/1117526/setting-the-vim-background-colors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!