james
james

Reputation: 139

Inverted colors in status line. Why?

I use gvim 7.4 on Windows, clean install, no plugins. Can anybody explain, why this:

highlight statusline guifg=red guibg=green

will show me green text on red background.

But this one:

highlight statusline gui=NONE guifg=red guibg=green

will show red text on green background?

(The actual goal was to change the text in statusline from bold to normal. For this task, I added gui=NONE and then, see this strange behaviour).

Edit

(As my answer to Kent's comment)

Here is my complete _vimrc. There are only two lines on code:

set laststatus=2
highlight statusline gui=NONE guifg=red guibg=green

Also tried:

Upvotes: 2

Views: 1726

Answers (2)

Kent
Kent

Reputation: 195029

To check how was a hi-group defined, in vim use: hi GroupName, that's why I keep asking OP and Carpetsmoker to provide their cmd output.

After vim has been compiled and installed, some default HL-Groups have been already defined.

From time to time people asked about the default color scheme. And want to extend the "default" color scheme. The location is easy to find, on a linux box, e.g. it locates at /usr/share/vim/vim74/colors/default.vim, different distributions could have different paths.

However if we open the default.vim, we will see a rather simple vim file. No any HL definition. Because they were in vim source codes as default defined.

Regarding the StatusLine group, it was defined in syntax.c file:

https://github.com/vim/vim/blob/8bc189e81aa98ba4aebb03a9dc9527a210fce816/src/syntax.c#L6784

We can see that the reverse is in StatusLine and StatusLineNC groups.

To get rid of the reverse "feature", you have to overwrite the gui or cterm attribute.

Upvotes: 4

Martin Tournoij
Martin Tournoij

Reputation: 27822

This is because the default StatusLine is:

:hi StatusLine
  StatusLine     xxx term=bold,reverse cterm=bold,reverse gui=bold,reverse

Notice the reverse keyword in cterm and gui? That tells it to use reverse video.

This is also why the colours are what you expect if you use gui=NONE (or gui=bold).

hi gives the same effect as highlight

hi is just the abbreviated version of highlight.

Upvotes: 1

Related Questions