Hi A.J.Mechelynck, you wrote:

> 
> 3. replace the arguments of guibg= and guifg= by their #RRGGBB hex
> equivalents from the rxvt color palette. What these equivalents are, I
> don't know; but you can set any 32-bit color that way. If you want it to
> be usable (without dithering) on a 256-color terminal, you should use red,
> green and blue components, each of which is a multiple of 0x33 (i.e., 00
> 33 66 99 CC or FF).
> 

Also, when choosing a color, it might make sense to take a look at file 
$VIMRUNTIME/rgb.txt which contains standard color names supported by VIM and 
which can be used in your colorschemes.
Some time ago I wrote a function which makes viewing the rgb.txt file more 
useful:

---%<------%<------%<------%<------%<------%<------%<------%<------%<------%<---
function! Byte2Hex(byte)
    let hex_chars = '0123456789ABCDEF'
    return hex_chars[a:byte / 16] . hex_chars[a:byte % 16]
endfunction

function! RGBHighlight()
    let line_idx = 1
    let num_lines = line("$")

    while line_idx <= num_lines
        let line = getline(line_idx)
        let line_idx = line_idx + 1

        if line =~ '^\s*\d\+\s\+\d\+\s\+\d\+\s\+.*$'
            let r = substitute(line, 
'^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(\d\+\)\s\+.*$', '\1', "")
            let g = substitute(line, 
'^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(\d\+\)\s\+.*$', '\2', "")
            let b = substitute(line, 
'^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(\d\+\)\s\+.*$', '\3', "")

            let hlcolor = Byte2Hex(r) . Byte2Hex(g) . Byte2Hex(b)
            let hlname = 'RGB' . hlcolor

            if !hlexists(hlname)
                exec "highlight " . hlname . " guifg=#" . hlcolor
                exec "syntax match " . hlname . ' /^\s*' . r. '\s\+' . g . 
'\s\+' . b . '\s\+.*$/'
            endif
        endif
    endwhile
endfunction

call RGBHighlight()
---%<------%<------%<------%<------%<------%<------%<------%<------%<------%<---

You can put it into a file, say, ~/rgb.vim and do

:e $VIMRUNTIME/rgb.txt
:source ~/rgb.vim

It will work absolutely correct only in Vim 7 since Vim 6 has support for very 
limited amount of syntax highlighting groups.

P.S. Tony, in the text above by "you" I mean the original poster, not you. :-)

-- 
Alexei Alexandrov

Reply via email to