change display colors. which rule causes which color?

55 views
Skip to first unread message

Gelonida N

unread,
Oct 1, 2012, 6:32:17 PM10/1/12
to vim...@googlegroups.com
I'm having terminal-windows with dark backgrounds.

The problem is, that all dark blue colors are very difficult to recognize.

Ideally I'd like to change all dark blue vim colors into a lighter blue
or another color.


My Questions:

Is there an easy way to globally change one color with another.

Alternatively.

If I see something in a color, that I don't like.

Is there any way to place my cursor on the 'badly' coloured word and
find out which rule set the color for that word?

Gelonida N

unread,
Oct 1, 2012, 6:32:35 PM10/1/12
to vim...@googlegroups.com

richard emberson

unread,
Oct 1, 2012, 7:00:26 PM10/1/12
to vim...@googlegroups.com
To see the "group" I use:

map <F10> :echo "hi<"
synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>

To see the colors associated with a group use:

:highlight "groupname"


I also have a color chooser
https://github.com/megaannum/forms/blob/master/images/examples_colorchooser.png

which is part of the Forms library:
https://github.com/megaannum/forms
http://www.vim.org/scripts/script.php?script_id=4150

and a color schemer viewer (built on top of Forms)
https://github.com/megaannum/colorschemer
http://www.vim.org/scripts/script.php?script_id=4240

Richard
--
Quis custodiet ipsos custodes

Gelonida N

unread,
Oct 2, 2012, 4:12:07 AM10/2/12
to vim...@googlegroups.com
On 10/02/2012 01:00 AM, richard emberson wrote:
> To see the "group" I use:
>
> map <F10> :echo "hi<"
> synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
>
> To see the colors associated with a group use:
>
> :highlight "groupname"
>
Thanks a lot for this tip.
This helps me to identify the groups, that are tricky to visualize.




Dominique Pellé

unread,
Oct 2, 2012, 4:17:20 AM10/2/12
to vim...@googlegroups.com
You can also show in the statusline the syntax group where cursor is located.
See:

http://vim.wikia.com/wiki/Showing_syntax_highlight_group_in_statusline

-- Dominique

geoffr...@thomsonreuters.com

unread,
Oct 2, 2012, 6:04:05 AM10/2/12
to vim...@googlegroups.com, gelo...@gmail.com
On Monday, 1 October 2012 23:33:17 UTC+1, Gelonida N wrote:
> The problem is, that all dark blue colors are very difficult to recognize.
> Ideally I'd like to change all dark blue vim colors into a lighter blue
> or another color.

I have the same problem with dark blue.

> Is there an easy way to globally change one color with another[?]

(Using Windows - not sure if this applies under other OSs.)
Most colours are ultimately defined in vim\vim73\rgb.txt (if
you're using VIM 7.3 of course).

You can simply define your own colour in there and then use
it in your colourscheme or whereever. I add this line

0 96 255 BobBlue

and then use it in my colourscheme:

exe 'hi SpecialKey guifg=BobBlue'
exe 'hi NonText guifg=BobBlue gui=NONE'
if !exists("$TERM")
hi SpecialKey ctermbg=DarkBlue ctermfg=White
hi NonText ctermbg=DarkBlue ctermfg=White
endif

You can define it directly in the colourscheme and avoid the
"exe" complication but then you can't use it in all other places,
as far as I could tell.

Since it doesn't work in DOS terminals I use DarkBlue
background with White text there instead.

You might be able to just edit the DarkBlue colour instead.
You'd have to try that to see. Some core colours
are defined elsewhere though - for example replace all the
colours in rgb.txt with 77 77 77 and gvim still shows the
colours like "red" as usual, although "red" is one of the
lines in the file.

Another problem is that rgb.txt is kept alongside the
executable and so upgrades to the vim version will lose your
changes. You'd expect there to be a way to define your own
colours under $VIMRUNTIME, e.g., include your own rgb.txt
there and have it added to the main colours, but I couldn't
find such a method.

Therefore I have the code below at the start of my _vimrc,
and I keep my BobBlue colour and other colours in the file
$VIMRUNTIME\rgb.txt

It doesn't feel very elegant and there's possibly a better
way to do it - works for me though.

regards,
Geoff

" Update rgb.txt with my custom colours - if they don't
" exist

" read in my colours and default colours from the file
let s:my_colours = readfile($VIM . "\\vimfiles\\rgb.txt")
let s:rgb_file = readfile($VIMRUNTIME . "\\rgb.txt")

let s:added_colours = 0
" for each of my colours
for s:my_colour in s:my_colours
let s:found=0
" for each of the default colours...
for s:line in s:rgb_file
"...found my colour?
if s:line =~ s:my_colour
let s:found=1
break
endif
endfor
"if didn't find my colour...
if s:found==0
" ... add it to the default colours
let s:rgb_file += [s:my_colour]
let s:added_colours += 1
endif
endfor
" if we changed the default colours, update the file
if s:added_colours > 0
call writefile(s:rgb_file, $VIMRUNTIME . "\\rgb.txt")
endif

Charles Campbell

unread,
Oct 3, 2012, 11:39:09 AM10/3/12
to vim...@googlegroups.com
Check out hicolors --

http://www.drchip.org/astronaut/vim/index.html#HICOLORS (cutting
edge)
http://vim.sourceforge.net/scripts/script.php?script_id=1081 (stable)

It gives help for highlighting colors by showing the name of the
highlight in
its currently selected color. Left-clicking on that color name will
bring you
to the help for it, and right-clicking on it will bring up a color editor.

Also, I suggest looking into using hilinks.vim:

http://www.drchip.org/astronaut/vim/index.html#HILINKS

This plugin provides a syntax stack trace and a highlighting stack trace
as you move your cursor about. In other words, as you move your cursor
about, hilinks will identify which syntax highlighting group is
responsible for what you see.

Regards,
C Campbell


Reply all
Reply to author
Forward
0 new messages