Incorrect colors with vim in iTerm2 using Solarized

后端 未结 11 1136
傲寒
傲寒 2020-12-07 07:43

I am having a strange issue with iTerm2, in terminal vim (non-gui) and the solarized color scheme. First, I have set iTerm2 to use the dark solarized colour scheme.

11条回答
  •  不知归路
    2020-12-07 07:59

    A couple of things to check:

    1. In iTerm2, in Preferences -> Profiles -> Terminal, under "Terminal Emulation" you have "Report Terminal Type:" set to xterm-256color.

    2. In your .vimrc, there are some options you can also set to make sure it's using 256 colors:

      set background=dark
      " solarized options 
      let g:solarized_visibility = "high"
      let g:solarized_contrast = "high"
      colorscheme solarized
      
      And one of those should work, but #1 first.

    BUT, if you're using the default, built in vim on Snow Leopard, it won't work, as it's not built with support for 256 colors. I believe the built in version in Lion does.

    Edit: Based on several comments on this answer, I've removed let g:solarized_termcolors = 256 line from the .vimrc example above. It appears that could be a problem for some. Another says that adding the line let g:solarized_termcolors = 16 fixed a color display problem. Your own mileage may vary.

    Second Edit: If you've loaded the solarized color palette into iTerm2, then you must let g:solarized_termcolors=16. Only let g:solarized_termcolors=256 if you are not using the solarized palette as your iTerm2 color preset.

提交回复
热议问题