Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define a custom RGB background colour in VIM?

Tags:

vim

Is it possible to define a custom RGB colour for the background colour of VIM?

At the moment I use set background=dark in my .vimrc which assigns #5D5D5D for the background colour. However, I would prefer to have #3F3F3F for my background colour.

like image 223
orschiro Avatar asked Dec 23 '13 13:12

orschiro


1 Answers

Normally your terminal will support only 256 colors, and they are numbered. If you want to use a particular color but don't know the number, the script gui2term.py will help you to find the most approximate one. Or you can just pick one from a table like this one.

If you are designing or modifying for your own color scheme for Vim, you can also use gui2term.py to translate those colors to the numbers.

Once you get the color number you'd like to use, you can edit your color scheme file. changing (or adding) the ctermbg value for the Normal and NonText group may be enough. E.g.:

highlight Normal guifg=#e0e0e0 guibg=#242424 gui=NONE ctermfg=254 ctermbg=235 cterm=NONE
highlight NonText guifg=#99968b guibg=#242424 gui=NONE ctermfg=246 ctermbg=235 cterm=NONE

There is a nice HTML Vim color scheme editor. You can try this to figure out which part uses which group and if you like, edit the colors visually (and run gui2term.py against the result file to make it support color terminals).

like image 108
lilydjwg Avatar answered Oct 17 '22 19:10

lilydjwg