Vim colorschemes not changing background in Ubuntu terminal

2

I have the following .vimrc:

set nocompatible              " Use vim defaults
"set ls=2                      " Always show status line
set showcmd                   " Show incomplete commands
set scrolloff=3               " Keep 3 lines when scrolling
set ruler                     " Show the cursor position all the time
set title                     " Show title in console title bar
set hid                       " Change buffer without saving
set showmatch                 " Show matching bracets

set ts=2                      " Numbers of spaces of tab character
set sw=2                      " Numbers of spaces to (auto)indent
set et                        " Tabs are converted to spaces, use only when required
set sts=2                     " Soft tab stop
set smartindent               " Smart indent
set autoindent
set nocindent
set wrap

set hlsearch                  " Highlight searches
set incsearch                 " Do incremental searching

And when I open vim from my Ubuntu 12.04 terminal, I see the colors of the scheme, but the background is the same that the one I open the terminal with. I would say the background should change, but I don't know why it doesn't.

Any help please?

Hommer Smith

Posted 2012-10-27T11:20:26.083

Reputation: 153

Why do you think background should change? – ZyX – 2012-10-27T12:57:25.147

Maybe because that's what's supposed to happen?

– romainl – 2012-10-27T19:22:58.190

What colorscheme? Does it have something like hi Normal ctermbg=something? What command to load the colorscheme? What's the output of $ echo $TERM? – romainl – 2012-10-27T19:28:18.003

@romainl I don't understand, he doesn't have any colorscheme in his .vimrc. why do you say it's supposed to happen? – none – 2012-10-28T01:28:52.100

If your colorscheme defines a background color you are supposed to see it instead of the terminal's background color. That's why I also ask how he is loading his colorscheme and what it is since I don't see any colorscheme in his vimrc. – romainl – 2012-10-28T06:07:31.980

But that's assuming he uses a specific, unnamed colorscheme. Of course, if he is only using the default colorscheme he won't see any change because **it doesn't define a background color". – romainl – 2012-10-28T06:12:18.220

Answers

1

try this to change bg color:

:set background=dark

or

:set background=light

to change your color scheme:

:colorscheme name

Edit colorscheme and set highlight commands, for instance;

highlight Normal ctermbg='color'

vivify is a nice place to get a new color scheme

b3h3m0th

Posted 2012-10-27T11:20:26.083

Reputation: 131

set background=… does exactly nothing with background. It just tells vim whether it should think that background is dark or light and adjust default colors accordingly. Does nothing for non-default colors (those that are changed by colorscheme). Is altered automatically when colorscheme redefines Normal highlighting group. And, by the way hi Normal ctermbg=color, no quotes. – ZyX – 2012-10-27T12:56:12.090

'color' stands for 'which color do you want'! I have given options to solve the problem! your -1 is excessive!!! – b3h3m0th – 2012-10-27T14:49:42.983

It is for “try this to change bg color: set background…”. It does never change the background. Color is not a problem (not that for -1): it is just uncommon to have 'color' as a placeholder for things like Red. It would be common if you used ctermbg=color or ctermbg={color}. I now know that ctermbg='Red' is accepted as well, but I do not see this acceptance stated in :h highlight-ctermfg, only in :h highlight-guifg. – ZyX – 2012-10-27T18:27:53.337

In fact, that line with hi comment guifg='salmon pink' is the only line where :highlight in help is used with single-quoted arguments (excluding 383’rd patch description in :h version6), neither I saw quoting in any colorschemes. – ZyX – 2012-10-27T18:32:53.543

1

Your ~/.vimrc doesn't contain any mention of a colorscheme.

That means that either:

  • you use the default colorscheme, or

  • you load a specific as yet unnamed colorscheme manually.

If you use the default colorscheme, what you see is normal. The default colorscheme doesn't define any background color so you are supposed to see your terminal's background color.

If you are loading a specific colorscheme, with :colorscheme colorscheme_name, and you don't see the background change colors, well… it could be because that colorscheme doesn't define a background color either. See if it contains something like Hi Normal ctermbg=color. But we can't debug it because you didn't post it.

I'd bet on the default colorscheme.

romainl

Posted 2012-10-27T11:20:26.083

Reputation: 19 227