13

I imported the solarized colorscheme and palette. My terminal has the correct colors and background, gvim has the correct colors and background, but vim has an incorrectly colored background. The text is all correct, but the background appears to be pure black.

This is a comparison of Terminal, GVim, and Vim

Here is my .vimrc:

syntax enable

if has('gui_running')
    set background=dark
else
    set background=dark
endif

:set t_Co=256
let g:solarized_termcolors=256
colorscheme solarized

If anyone has any suggestions on what could be causing this, I would be much obliged. I run xubuntu with the default terminal.

I should also mention that the light option results in a very yellow background for Vim.

  • 1
    By "[m]y terminal has the correct colors and background," do you mean to say that you followed the specific advice regarding Vim in the terminal? – Andrew Feb 20 '15 at 2:35
  • 2
    I did follow the advice, @Andrew. Thank you though. – Oberdiear Feb 20 '15 at 3:43
  • @Oberdiear The advice Andrew links to explains that you should set up your terminal to use solarized colours, and not use the g:solarized_termcolors=256 option. If you're happy to use solarized colours in your terminal, this method works much better. The text of your question implies you have set up your terminal to use solarized colours (although the screenshot you display doesn't look to me like it does), so in that case, why are you using the g:solarized_termcolors=256 setting? – Rich Feb 20 '15 at 9:01
  • What terminal are you using? I have this script for gnome-terminal. – wchargin Feb 21 '15 at 0:24
  • @Rich, I guess that I don't have the palette set up correctly. Do you (or someone else) know how to correctly set that up for Xfce Terminal? – Oberdiear Feb 23 '15 at 14:23
10

There's two reasons why I think this may be happening:

  1. The solarized color scheme you are using does not declare ctermfg and ctermbg for any of the features you want to highlight. Try out this color scheme, should look essentially the same both inside your terminal and gvim, if this is the case then you may need to look into using a color scheme that declares ctermfg and ctermbg.

  2. You may need to make sure your terminal emulator supports the colors you are trying to display:


Note that both of this things could be happening at the same time, but it is hard to diagnose this without more information about your system.

  • The desert256 works fine, but I am not a huge fan. I do believe the TERM variable is incorrect, but I have no idea how to change it. – Oberdiear Feb 20 '15 at 3:54
  • 2
    I installed ncurses-term. I then ran the command. After I run it, all text becomes grey and the background is black. – Oberdiear Feb 20 '15 at 5:01
  • 1
    It should be export TERM=xterm+256color, NOT "colors" (plural). Also, I believe that is should be xterm-256color, NOT "**+**256color; but I may be wrong specifically about using it with solarized. According to this answer, # Entries with embedded plus signs are designed to be included through use/tc capabilities, not used as standalone entries. – Edward Dec 21 '17 at 0:47
  • export TERM=xterm+256color on OSX I get zle-line-finish:echoti:1: no such terminfo capability: rmkx – Xeoncross Apr 23 '18 at 16:15
  • I had this exact issue and export TERM=xterm+256colors helped vim solarized detect and use the exact background color as what my terminal has. – Shyam Habarakada May 30 '18 at 19:10
5

Great news, everyone. @Tom and @Rich set me on the right path. I found a solution provided here. I set my .vimrc to the simple

syntax enable
set background=dark
set t_Co=16
colorscheme solarized

This seems to fix everything. The colors don't seem to be as bright in the font examples, but that could very well just be me. To anyone who wants to use the Solarized colorscheme and uses xfce4-terminal, just changing the terminalrc and the .vimrc seemed to solve my main problems. Thanks to everyone for your help!

  • You shouldn't need the set t_Co line in your vimrc: Vim can read this value from the terminal (Setting 't_Co' seems to be a bit of a Vim cargo cult: lots of people online recommend doing so without really understanding the issues they're attempting to solve.) – Rich Jan 15 '16 at 10:50
  • I'll just say "screen" and "tmux" - these tools change the $TERM variable so vim can't read the information it needs. – NieDzejkob Sep 8 '17 at 15:49
  • @NieDzejkob You can use a terminal multiplexer and still have a correctly-configured terminal. – Rich Oct 6 '17 at 13:14
4

I guess it is an issue of compatibility of this colorscheme with terminal. The plugin csaprox miraculously solve a bunch of this issues.

Synopsis:

It's hard to find colorschemes for terminal Vim. Most colorschemes are written to only support GVim, and don't work at all in terminal Vim.

This plugin makes GVim-only colorschemes Just Work in terminal Vim, as long as the terminal supports 88 or 256 colors - and most do these days. This usually requires no user interaction (but see the help for what to do if things don't Just Work). After getting this plugin happily installed, any time you use :colorscheme it will do its magic and make the colorscheme Just Work.

Links to the plugin:

  • 1
    This is a useful plugin, but won't help here, as the solarized colorscheme already goes to considerable effort to work in terminal Vim under both 16-color and 256-color terminals. – Rich Feb 23 '15 at 15:52
4

The solarized terminal-Vim colorscheme can work in one of two different ways.

  1. A 16-colour mode: Solarized only contains 16 colours, so in this mode you set your terminal to use the solarized colours as its 16 colours, and the Vim colorscheme just uses these. So for example, the Vim colorscheme will request terminal colour "1", and the terminal displays this as the hex colour #dc322f.

  2. A 256-colour mode, where it picks the closest matches for its 16 colours from a 256-color palette.

The former method is strongly recommended by the author (and by me), and it sounds as though you are happy to use this method because you state that your "terminal has the correct colors and background".

However, it appears from your screenshot that your terminal does not have the correct colours set. (White is not a colour in the solarized set, and although I haven't eyedroppered it, the other text colour in the screenshot doesn't look to me like it's Solarized "Violet" (#6c71c4), either.)

If you remove the lines setting t_Co and g:solarized_termcolors from your vimrc*, and configure your terminal colours correctly, then you should find that the 16-colour solarized colorscheme will start to work.

* These lines switch solarized to using its (less faithful) 256-colour mode. This should also work, (I suspect that @Jubal is correct in suggesting that BCE is the problem here), but the 16-colour mode is preferable unless you explicitly don't want to use solarized in your terminal.

  • I believe you are completely on the right track. I think I don't have the palette installed correctly. Could you walk me through the process? I appreciate all your help, @Rich. – Oberdiear Feb 23 '15 at 18:29
  • 1
    It appears your first link is now dead. – akozi Feb 12 at 22:12
  • @azoki Thanks for letting me know. Looks like the Solarized site is under (re)construction. I changed the link to point into the github repo for the time being. – Rich Feb 13 at 9:32
3

Seems like you found your answer. I had this same problem and nothing above worked. What worked for me was using altercation's terminalrc, as opposed to sgerrand's.

My relevant vimrc is simply:

syntax enable
set background=dark
colorscheme solarized

Hope that helps someone!

1

So this is what works for me (on all terminals I used to use – xterm, konsole, gnome-terminal, iterm2, roxterm – on both Linux and OS X, also with gvim and macvim):

" no other configuration than this needed for solarized
colorscheme solarized
highlight SpecialKey ctermfg=11 ctermbg=8

if &term =~ '256color'
  " Disable Background Color Erase (BCE) so that color schemes work
  " properly within 256-color terminals
  set t_ut=
endif
  • This caused a similar problem to setting t_Co=16. I'm fairly certain I have a problem with the palette, but I have yet to figure it out. – Oberdiear Feb 23 '15 at 14:48
  • What terminal emulator are you using? If I recall correctly, konsole's built-in solarized configuration is not fully usable and one needs to use settings from the original solarized repository… – Jubal Feb 23 '15 at 15:45
  • I use Xfce Terminal. – Oberdiear Feb 23 '15 at 16:30
  • I think I got it working: try to force TERM to xterm-256color, while using the solarized preset from the terminal's preferences, not from the solarized xfce-terminal git repository. This along with the BCE hack above did the trick for xfce4-terminal for me. – Jubal Feb 23 '15 at 20:08
  • (There's still something fishy with the underlying terminal emulation and font rendering, and I guess I got reminded why I went back to plain old xterm on Linux…) – Jubal Feb 23 '15 at 20:12
0

This was a pain to get working (I use terminal Vim in Linux Mint), and unfortunately I didn't write down the specifics of everything I did. Here is the relevant section of my vimrc:

syntax enable
set background=dark
set t_Co=16
colo solarized

It may also be worth checking out this project on GitHub.

  • set t_Co=16 causes the colors to be radically different from what is expected. I am also using the default Xubuntu terminal is Xfce-Terminal. – Oberdiear Feb 20 '15 at 5:57
  • @Oberdiear If setting t_Co=16 affects the colours in that way (with the g:solarized_termcolors variable unset) then that means that your terminal colours are not set up correctly to use solarized. How are you setting your terminal colours? – Rich Feb 20 '15 at 11:58
0

What worked for me was to remove this part of your settings

if has('gui_running')
   set background=dark
else
   set background=dark
endif

I am running a xfce4-terminal

0

I had this problem too with xfce-terminal.

After a bit of research, I discovered this bug: anything you set as $TERM in your XFCE terminal is silently ignored.

I think this is really a bug of the underlying (and unmaintained) old VTE library that XFCE terminal (still GTK+2 based) uses. Switching to a GTK+3 terminal, that implicitely uses the new VTE library, solved the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.