How can i get know what color the syntax highlight is using?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How can i get know what color the syntax highlight is using?

Woody Wu

i want to change some color of syntax highlight. i knew there is a rgb database
in X and i can touch it. the problem of the solution is, i wouldn't know what's
the name of the color i want to change.

currently, there are two colors i dont like. the first, those very dark blue
used for comments of c/c++ code;  second, the color use to highlight
search-matched word in a file -- it's too ligh to see the word itself.

thanks in advance.

--
steven woody (id: narke)

Jesse: I heard this story once about when the Germans were occupying
Paris and they had to retreat back. They wired Notre Dame to blow,
but they had to leave one guy in charge of hitting the switch. And
the guy, the soldier, he couldn't do it. You know, he just sat
there, knocked out by how beautiful the place was. And then when
the allied troops came in, they found all the explosives just
lying there and the switch unturned, and they found the same thing
at Sacre Couer, Eiffel Tower. Couple other places I think...
Celine: Is that true?
Jesse: I don't know. I always liked the story, though.

        - Before Sunset (2004)

Reply | Threaded
Open this post in threaded view
|

Re: How can i get know what color the syntax highlight is using?

John (Eljay) Love-Jensen
Hi Steven,

I concur with your opinion regarding the comment highlight color.

Here's my solution, that I use across three disparate platforms:

~/.vim/after/syntax/syncolor.vim
----------------------------------------------------------------------
if $TERM == "cygwin"
  hi Comment ctermfg=0 cterm=bold
endif

if $TERM == "teraterm"
  hi SpecialKey ctermfg=7
  hi Comment ctermfg=0 cterm=bold
  hi DiffText ctermfg=0 cterm=NONE
endif

if $TERM_PROGRAM == "Apple_Terminal"
  hi Comment ctermbg=0 ctermfg=8 cterm=NONE
  hi search ctermfg=0
  hi Folded term=NONE ctermfg=7 ctermbg=4
endif
----------------------------------------------------------------------

HTH,
--Eljay

Reply | Threaded
Open this post in threaded view
|

Re: How can i get know what color the syntax highlight is using?

Tim Chase-2
In reply to this post by Woody Wu
> i want to change some color of syntax highlight. i knew there
> is a rgb database in X and i can touch it. the problem of the
> solution is, i wouldn't know what's the name of the color i
> want to change.
>
> currently, there are two colors i dont like. the first, those
> very dark blue used for comments of c/c++ code;  second, the
> color use to highlight search-matched word in a file -- it's
> too ligh to see the word itself.

Generally one doesn't want to bung with the system files,
redefining the name of, say "cerulian" to some other color.

To change your colors, you can either pick an entirely new
colorsheme, or tweak one that you otherwise like.

To see what colorschemes you have available, type ":colorscheme "
and then hit control+D.  This will list the ones you have on your
system.  If you find one you like (such as "elflord"), you can
just use that by doing

        :colorscheme elflord

(or to make it perm., put "colorscheme elflord" in your vimrc file).

If you have one that you *mostly* like, but want to change/tweak
a bit, you can copy the colorscheme to your $HOME/.vim/colors
directory, rename it, and edit it to your heart's desire.

Be sure to change the value of

        g:colors_name

to that of your file.  I've gone the latter route to the extreme
and have my own colorscheme, setting all the colors I prefer.

If you don't know your current colorscheme, you can simply do

        :echo g:colors_name

Just a few ideas,

-tim







Reply | Threaded
Open this post in threaded view
|

Re: How can i get know what color the syntax highlight is using?

Charles E Campbell Jr
In reply to this post by Woody Wu
Steven Woody wrote:

>i want to change some color of syntax highlight...snip
>  
>

>currently, there are two colors i dont like...snip
>  
>
Hello!

The first thing is to consider whether you have a dark or light
background and to set the option accordingly:

    :set bg=dark
    :set bg=light

in your <.vimrc>.

As an aid to determining what syntax highlighting group is responsible
for some color, you can put your cursor on the item and hit the <F10>
key with the following tip:

    http://vim.sourceforge.net/tips/tip.php?tip_id=99
    "How to tell what syntax highlighting group *that* is!"

A more complete list of the syntax highlighting chain can be obtained
with \hlt, a map available from

    http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs - see
"HiLinkTrace"

Of course, you can try using any of a rather large number of
colorschemes available at http://vim.sf.net/.  Robert Metacosm has a
colorscheme sampler, too:
http://vim.sourceforge.net/scripts/script.php?script_id=625

Alternatively, you may like some colorscheme, except for a few colors,
or perhaps you'd like to come up with your own colorscheme.  For that
purpose you may wish to use hicolors.vim, a plugin which shows you the
standard syntax highlighting group names in their own currently
colorscheme-assigned colors, plus gives you can editor so you can modify
them.  That plugin is available at:

    http://vim.sourceforge.net/scripts/script.php?script_id=1081

Regards,
Chip Campbell

Reply | Threaded
Open this post in threaded view
|

Re: How can i get know what color the syntax highlight is using?

Gary Johnson
In reply to this post by Woody Wu
On 2005-11-04, Steven Woody <[hidden email]> wrote:
> i want to change some color of syntax highlight. i knew there is a rgb database
> in X and i can touch it. the problem of the solution is, i wouldn't know what's
> the name of the color i want to change.
>
> currently, there are two colors i dont like. the first, those very dark blue
> used for comments of c/c++ code;  second, the color use to highlight
> search-matched word in a file -- it's too ligh to see the word itself.
>
> thanks in advance.

I agree with others that changing your colorscheme is the easiest
approach.  However, that will only get you so far when using a
terminal such as a 16-color xterm.  You are limited to the 16 colors
of the xterm's palette.

You can see the colors available by following the instructions at
":help colortest.vim".  You can see how vim selects these colors
from the terminal's palette by executing ":hi".  Note that the GUI
colors (guifg and guibg) have names while the color terminal colors
(ctermfg and ctermbg) have numbers.  The numbers used depend on the
number of colors the terminfo database says your terminal ($TERM)
supports.  If you're interested, you can find this out by executing
":set t_Co?".  When I do this I get "t_Co=16".

At the bottom of the list returned by ":hi" you will see a set like
this:

    col_black      xxx ctermfg=0 guifg=black
    col_darkred    xxx ctermfg=1 guifg=darkred
    col_darkgreen  xxx ctermfg=2 guifg=darkgreen
    col_brown      xxx ctermfg=3 guifg=brown
    col_darkblue   xxx ctermfg=4 guifg=darkblue
    col_darkmagenta xxx ctermfg=5 guifg=darkmagenta
    col_darkcyan   xxx ctermfg=6 guifg=darkcyan
    col_lightgray  xxx ctermfg=7 guifg=lightgray
    col_darkgray   xxx ctermfg=8 guifg=darkgray
    col_red        xxx ctermfg=9 guifg=red
    col_green      xxx ctermfg=10 guifg=green
    col_yellow     xxx ctermfg=11 guifg=yellow
    col_blue       xxx ctermfg=12 guifg=blue
    col_magenta    xxx ctermfg=13 guifg=magenta
    col_cyan       xxx ctermfg=14 guifg=cyan
    col_white      xxx ctermfg=15 guifg=white
    col_grey       xxx ctermfg=7 guifg=grey
    col_lightred   xxx ctermfg=9 guifg=lightred
    col_lightgreen xxx ctermfg=10 guifg=lightgreen
    col_lightyellow xxx ctermfg=11 guifg=lightyellow
    col_lightblue  xxx ctermfg=12 guifg=lightblue
    col_lightmagenta xxx ctermfg=13 guifg=lightmagenta
    col_lightcyan  xxx ctermfg=14 guifg=lightcyan

Depending on the filetype being edited, the ":hi" list should also
include a definition for the Comment highlight, which by default is:

    Comment        xxx term=bold ctermfg=4 guifg=Blue

So you can see that on a color terminal, by default, vim uses color
number 4 for comments, which is supposed to be a dark blue.

I always have my xterms set to use a black background.  On my
system, color number 4 is so dark as to be useless, so I've
lightened it.  You can choose the 8 or 16 colors of your terminal
from the X server's huge palette with statements like these in your
~/.Xdefaults file:

    XTerm*VT100*color4: blue
    XTerm*VT100*color4: skyblue
    XTerm*VT100*color4: #70a0ff

where the right side can be a color name from rgb.txt or a
red-green-blue triplet in hex.

An application such as kcolorchooser can help you tweak the red,
green and blue components for a color you like.

Using the ~/.Xdefaults file this way has helped make the colored
text in vim more readable, but that in mutt and tin more readable,
too.

The highlight that vim uses to highlight search matches is Search
and by default is:

    Search         xxx term=reverse ctermbg=11 guibg=Yellow

If I'm using PuTTY, I change this with this in my ~/.vimrc:

    highlight clear Search
    highlight Search term=bold ctermfg=black ctermbg=3

When using an xterm, I set it this way:

    highlight clear Search
    highlight Search term=bold cterm=bold gui=bold

and in my ~/.Xdefaults I have

    ! Bold attribute
    !
    XTerm*VT100*colorBDMode: on
    XTerm*VT100*colorBD: #ffffa0
    ! ! a medium yellow

You can find out more about xterm color settings in the xterm man
page.

HTH,
Gary

--
Gary Johnson                 | Agilent Technologies
[hidden email]     | Wireless Division
                             | Spokane, Washington, USA