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 use the Solarized palette. I’ve included palettes for some popular terminal emulator as ...
According to the readme of the vim sector of ethan's solarized colorscheme, you need to set the colorscheme of your terminal explicitly. You can take a look at base 16. Install it, and run base16_solarized-dark. Then vim will, hopefully, show the colors properly. And also put this in your vimrc:
in place of
That part of the documentation explains it.
I've included palettes for some popular terminal emulator as well as Xdefaults in the official Solarized download available from Solarized homepage.
You need to use one of these palettes depending on the terminal client you're using.
This is unrelated to vim.
If you want to toggle background, add this to your vimrc, (edit mapping according to what you like)
I use this on OS X 10.10.2 on iTerm
if &background == "light"
execute ":set background=dark"
execute ":set background=light"
nnoremap <leader>ct :call BgToggleSol()<cr>
Check out ...
Something is definitely not right.
I have in my .vimrc something like this:
And when I do :set bg? after that, it shows "light".
I think that's the reason the if/else/endif in you function doesn't work after 'colorsheme solarized'.
The only workaround I can think of is to maintain the state in a separate variable:
You can't get the "right" colors in a terminal emulator because the colors used for highlighting are defined as "red" or "bright cyan" which are then user-defined at the terminal emulator level and could mean anything, especially in the case of Solarized where "bright cyan" is actually a freaking grey.
You can get the "right" colors in GVim, though, because ...
Try adding to ~/.tmux.conf:
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ',*:RGB'
# for older tmux
# set -ag terminal-overrides ',*:Tc'
Might be interesting:
First colorscheme solarized must be after let g:solarized_termcolors=256, and that may work.
If not. You should set xterm-256 color in preferences.
Bellow you can see the settings that works for me nicely. I don't use a keymap for toggle background, instead just use :set bg=light or :set bg=dark
" Pathogen plugins