Setup vimrc with solarized color theme
Matthew Harrington
I just started with vim in ubuntu, and have some trouble setting up my .vimrc file. This is what I currently have:
"============= Solarized color theme ============= " syntax enable "Use syntax highlighting set background=dark "Use dark color scheme colorscheme solarized "Choose solarized "============= Settings ============= set nocompatible "Necesary for cool vim things set number "Line numbers set colorcolumn=80 "Have a line after 80 char set ruler "Add ruler at the bottom of vim set cursorline However, when I can't see my cursorline and the colorcolumn with these settings. If I don't use the solarized color syntax, I do see them. Do you guys know what I am doing wrong?
23 Answers
By setting t_Co to 256 what you'll get is a degraded version of Solarized.
It's better to update your terminal color palette instead for more precise colors.
set t_Co=16
let g:solarized_termcolors=16By setting t_Co and solarized_termcolors to 16 we tell Vim and Solarized to use terminal's color palette.
So, check for these:
You should
set t_Co=256in your vimrc. (read here more)You should edit the colors on your terminal, following a solarized colorscheme. Check this.
I use
syntax onbut I believesyntax enableshould do the work too.Put the solarized theme in
~/.vim/colors
Let me know if it does work after following all these steps.
0From 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 solarizedline:let g:solarized_termcolors=256Again, I recommend just changing your terminal colors to Solarized values either manually or via one of the many terminal schemes available for import.
What worked for me on Ubuntu 16.04 with the included Terminal application was to simply select Solarized for both "Text and Background Color" (choose light or dark) and "Palette" in Terminal > Preferences > Profiles > (select yours) > Edit > Colors
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) colorscheme.