vim 使用 iterm2 不能使用 colorscheme

vim using iterm2 cannot use colorscheme

所以我正在尝试在 mac 上的 iterm2 中获得 colorscheme 支持。当我 :colorscheme solarized 这就是我的屏幕的样子

这是我的主要 .vimrc

set nocompatible

let mapleader = ","

set backspace=2
set nobackup
set nowritebackup
set noswapfile
set history=50
set ruler
set showcmd
set incsearch
set laststatus=2
set autoread

set ignorecase
set smartcase

set tabstop=2
set shiftwidth=2
set shiftround

set list listchars=tab:»·,trail:·,nbsp:·

set textwidth=80
set colorcolumn=+1

"set number

set splitbelow
set splitright

set winwidth=84
set winheight=5
set winminheight=5
set winheight=999

set matchpairs+=<:>

" Treat <li> and <p> tags like the block tags they are
let g:html_indent_tags = 'li\|p'

set scrolloff=8
set sidescrolloff=15
set sidescroll=1

"if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on")
"  syntax on
"   set t_Co=256
"   set background=dark
"endif

" Load up all of our plugins
if filereadable(expand("~/.vimrc.bundles"))
  source ~/.vimrc.bundles
endif

filetype plugin indent on

这是我的插件文件

if &compatible
      set nocompatible
    end

    filetype off
    set rtp+=~/.vim/bundle/Vundle.vim/
    call vundle#begin()
Plugin 'gmarik/Vundle.vim'

Plugin 'christoomey/vim-tmux-navigator'
Plugin 'christoomey/vim-tmux-runner.git'
Plugin 'christoomey/vim-run-interactive'
Plugin 'vim-scripts/ctags.vim'
Plugin 'scrooloose/syntastic' "Syntax Highlighting
Plugin 'scrooloose/nerdtree'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'ervandew/supertab'
Plugin 'vim-scripts/tComment'
Plugin 'vim-scripts/HTML-AutoCloseTag'
Plugin 'jiangmiao/auto-pairs'
Plugin 'tpope/vim-fugitive' "Make git awesome
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-surround'

Plugin 'Slava/vim-spacebars'
Plugin 'groenewege/vim-less'

Plugin 'altercation/vim-colors-solarized'
Plugin 'bling/vim-airline' "Awesome looking meta at bottom
Plugin 'majutsushi/tagbar'

Plugin 'vim-scripts/matchit.zip'
Plugin 'vimwiki/vimwiki'
Plugin 'mattn/calendar-vim'

    call vundle#end()
    filetype on

    set t_Co=256
    set background=dark
    syntax enable

我进入了iterm的设置,将终端的报告设置为xterm-256color。我还在我的 .zshrc 中添加了以下行

export CLICOLOR=1
export TERM=xterm-256color

您也需要在您的终端上安装 solarized colorscheme。

来自 solarized-vim 自述文件:

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.

您应该从 here 下载 solarized 包并解压缩。

然后打开iTerm 2,前往iTerm -> Preferences -> Profiles -> Colors。在底部它应该说 Load Presets。单击它并选择靠近底部的 import。转到下载的 solarized 文件夹所在的位置,然后选择 solarized/iterm2-colors-solarized/Solarized Dark(或 Solarized Light)。然后 Solarized Dark(或 Light)应该在下拉菜单中。

然后一切都应该正常工作。