2

I've installed solarized with the bundled togglebg.vim plugin.

In my vimrc I set background to light and colorscheme to solarized, so I have light background and matching font colors from solarized-light.

When I change background to dark in my vimrc and restart vim, it starts with dark background and matching colors from solarized-dark - as advertised.

But when I use togglebg, it changes background to dark (but not dark like in solarized, almost black) and to some different colorscheme. Manual :colorscheme solarized doesn't fix the problem. After running togglebg double it doesn't go back to first state, but to solarized-light scheme with the same almost black background.

I have only solarized with togglebg, ctrlP and Powerline installed.

Vim running in iTerm on OS X 10.8.5

Here's my full .vimrc:

execute pathogen#infect()                                                                                          

syntax enable                                                                                                      
set background=light                                                                                               
colorscheme solarized                                                                                              
set t_Co=256                                                                                                       
let g:solarized_termcolors=256                                                                                     

let g:Powerline_symbols='fancy'                                                                                    

set encoding=utf-8                                                                                                 
filetype plugin indent on                                                                                          

set nocompatible                                                                                                   
set modelines=0                                                                                                    

set tabstop=2                                                                                                      
set shiftwidth=2                                                                                                   
set softtabstop=2                                                                                                  
set expandtab                                                                                                      

set ruler                                                                                                          
set relativenumber                                                                                                 

set laststatus=2                                                                                                   

set ignorecase                                                                                                     
set smartcase                                                                                                      
set gdefault                                                                                                       

inoremap jk <Esc>                                                                                                  
call togglebg#map("<F5>")   
2

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

function! BgToggleSol()
  if &background == "light"
    execute ":set background=dark"
  else
    execute ":set background=light"
  endif
endfunction

nnoremap <leader>ct :call BgToggleSol()<cr>

Check out git for more.

Tip: Since you are using a mac, pasting using Command+V must be a pain. Add this to your vimrc as well

if &term =~ "xterm.*"
    let &t_ti = &t_ti . "\e[?2004h"
    let &t_te = "\e[?2004l" . &t_te
    function XTermPasteBegin(ret)
        set pastetoggle=<Esc>[201~
        set paste
        return a:ret
    endfunction
    map <expr> <Esc>[200~ XTermPasteBegin("i")
    imap <expr> <Esc>[200~ XTermPasteBegin("")
    cmap <Esc>[200~ <nop>
    cmap <Esc>[201~ <nop>
endif
1

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 
execute pathogen#infect()

filetype on
filetype indent on
filetype plugin on

" Enable syntax colors
syntax enable

" Background color from color  scheme
set background=dark
" set background=light

" Solarized scheme color preferences
let g:solarized_termcolors=256
let g:solarized_termtrans = 1
let g:solarized_degrade = 0
let g:solarized_bold = 1
let g:solarized_underline = 1
let g:solarized_italic = 1
let g:solarized_contrast = "normal"
let g:solarized_visibility= "normal"
colorscheme solarized

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.