Ubuntu, Vim, and the solarized color palette

58,544

Solution 1

Here's my recommendation for things to try:

  1. ensure syntax on is in your .vimrc file
  2. Check what t_Co Vim has picked up from your term emulator (a quick :echo &t_Co). If it's 8, you'll want to se t_Co=16. You might also try se t_Co=256 though without let g:solarized_termcolors=16 this will use the 256 fallback mode, which isn't quite the correct color scheme.

Solution 2

set t_Co=16 and let g:solarized_termcolors=16 did not work for me. This is what worked:

syntax on
let g:solarized_termcolors=256
set t_Co=256 
set background=dark
colorscheme solarized

Solution 3

I found out how do do it from this article.

I wrote the following script to do the gnome-terminal stuff.

gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_background" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_colors" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/palette" --type string "#070736364242:#D3D301010202:#858599990000:#B5B589890000:#26268B8BD2D2:#D3D336368282:#2A2AA1A19898:#EEEEE8E8D5D5:#00002B2B3636:#CBCB4B4B1616:#58586E6E7575:#65657B7B8383:#838394949696:#6C6C7171C4C4:#9393A1A1A1A1:#FDFDF6F6E3E3"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/background_color" --type string "#00002B2B3636"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/foreground_color" --type string "#838394949696"

Solution 4

If you are trying to use Vim with solarized inside of tmux, this is the fix for your issue:

Fix solarized theme in tmux

Solution 5

From the README (emphasis mine):

IMPORTANT NOTE FOR TERMINAL USERS:

If you are going to use Solarized in Terminal mode (i.e. not in a GUI version like gvim or macvim), please please please consider setting your terminal emulator's colorscheme to used the Solarized palette. I've included palettes for some popular terminal emulator as well as Xdefaults in the official Solarized download available from [Solarized homepage]. If you use Solarized without these colors, Solarized will need to be told to degrade its colorscheme to a set compatible with the limited 256 terminal palette (whereas by using the terminal's 16 ansi color values, you can set the correct, specific values for the Solarized palette).

If you do use the custom terminal colors, solarized.vim should work out of the box for you. If you are using a terminal emulator that supports 256 colors and don't want to use the custom Solarized terminal colors, you will need to use the degraded 256 colorscheme. To do so, simply add the following line before the colorschem solarized line:

let g:solarized_termcolors=256

Again, I recommend just changing your terminal colors to Solarized values either manually or via one of the many terminal schemes available for import.

Simply selecting Solarized for both "Text and Background Color" (choose light or dark) and "Palette" in TerminalPreferencesProfiles → (select yours) → EditColors worked for me on Ubuntu 16.04 (Xenial Xerus) with the included Terminal application.

Some other answers recommend choosing a 256 color palette but, as mentioned in the documentation, this gives you a degraded (and visibly worse in my opinion) color scheme.

Share:
58,544

Related videos on Youtube

danwoods
Author by

danwoods

Javascript developer working as front-end engineer.

Updated on July 08, 2022

Comments

  • danwoods
    danwoods almost 2 years

    I'd really like to get in on all the colorful goodness of the solarized colorscheme, but I can't seem to get it configured just right.

    I have the main solarized file in my .vim/colors folder, I've set my terminal profile colors to what is listed on the site, and I've added the lines

     set background=dark
     let g:solarized_termcolors=16
     colorscheme solarized
    

    to my .vimrc file, but Vim looks greyed out and is using a bright green color as the default. How can I do it?

  • danwoods
    danwoods about 13 years
    Holy crap, didn't expect an answer from the author! Thanks altercation, I'll try your recommendations and shoot you an email later today.
  • Martin Janiczek
    Martin Janiczek almost 13 years
    t_Co is what was the problem on my Ubuntu box too. I installed the gnome-terminal-colors-solarized package, but it wasn't using the right background color. se t_Co=16 did the trick. Thanks!
  • Chris Wesseling
    Chris Wesseling over 12 years
    I think the foreground colour on a dark background should be "base0" not "base00". So the last line should be gconftool-2 --set "/apps/gnome-terminal/profiles/Default/foreground_color" --type string "#838394949696"
  • t-mart
    t-mart over 12 years
    Ahh, you know, i always thought that was off. Thanks!
  • rev
    rev over 12 years
    order apparently matters as well. i found that set t_Co=16 after colorscheme solarized doesn't work. you have to set t_Co before the colorscheme.
  • Setheron
    Setheron about 11 years
    I find my blank/empty lines are not the same background color. How do i fix this?
  • malvim
    malvim almost 10 years
    This. This worked perfectly for me after just over an hour of looking around. Thank you!
  • Eliethesaiyan
    Eliethesaiyan over 9 years
    it fixed the issue but messed up the original colors of files and folders....i wanted solarized only in vim or at least keep the highlight of folders and files(executables) now everything looks the same..any workaround?
  • user798275
    user798275 over 8 years
    I needed syntax on before the rest (I had it after) plus let g:solarized_termcolors=256 . Thanks!
  • PeterT
    PeterT over 7 years
    I spent two hours trying to figure this out, turns out solarized_termcolors=256 was my problem -AND- that it must appear before changing the colorscheme.
  • kleinfreund
    kleinfreund about 7 years
    The article you linked to in your answer is no longer available. This answer now lacks necessary context/explanation.
  • kleinfreund
    kleinfreund about 7 years
    I do syntax on, let g:solarized_termcolors=256, set background=dark and colorscheme solarized but it’s not quite correct. Also I use Pathogen.
  • Jim Stewart
    Jim Stewart over 6 years
    This was the only solution that worked for me. I was using the Solarized Dark gnome-terminal scheme that Ubuntu ships with, and while it looked fine in the shell itself, Vim looked like a mess. Some of the other answers here (tweaking Vim config) helped get it close to right, but the background color was still black or grey, rather than the slate-blue it's supposed to be. Installing this replacement gnome-terminal colorscheme fixed it with my default Vim config.
  • Richard Möhn
    Richard Möhn over 5 years
    Selecting the palette was the part that I missed at first.
  • Krish
    Krish about 3 years
    For clarity, "Terminal > Preferences" means "Right click on terminal and select preferences"