Incorrect colors with vim in iTerm2 using Solarized

后端 未结 11 1087
傲寒
傲寒 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:50

    https://github.com/altercation/solarized/tree/master/iterm2-colors-solarized

    Download Solarized package (https://github.com/altercation/solarized) and follow instructions:

    Open iTerm 2, open Preferences, click on the "Profiles" (formerly Addresses, formerly Bookmarks) icon in the preferences toolbar, then select the "colors" tab. Click on the "load presets" and select "import...". Select the Solarized Light or Dark theme file.

    You have now loaded the Solarized color presets into iTerm 2, but haven't yet applied them. To apply them, simply select an existing profile from the profile list window on the left, or create a new profile. Then select the Solarized Dark or Solarized Light preset from the "Load Presets" drop down.

    ====================================

    Or:

    cd ~/.vim/bundle
    git clone git://github.com/altercation/vim-colors-solarized.git
    

    Modify .vimrc

    Dark Theme:

    syntax enable
    set background=dark
    colorscheme solarized
    

    Light

    syntax enable
    set background=light
    colorscheme solarized
    
    0 讨论(0)
  • 2020-12-07 07:53

    A simple way to solve this problem is:

    In colors dir on vim-color-solarized exist an arquive named 'solarozed.vim'

    Open this file and search:
    exe "let s:bg_back = ' ".s:vmode."bg=".s:back ."'"

    replace to:
    exe "let s:bg_back = ' ".s:vmode."bg=".s:none ."'"

    0 讨论(0)
  • 2020-12-07 07:55

    Bill Turner's answer works, but there is a way to get the colors to match MacVim exactly. Solarized has support specifically for iTerm2, among other terminal emulators.

    1. Go to the iterm2-colors-solarized github page
    2. Follow the instructions under "Installation"
    3. Make sure your .vimrc has the line colorscheme solarized

    This should set the vim colors in iTerm2 to be exactly as they are in gui editors.

    0 讨论(0)
  • 2020-12-07 07:57

    The above answers didn't work for me.

    I'm using iTerm2 with vim 7.3 on OS X 10.7.4.

    If the above solutions didn't work for you too, try this

    syntax on
    set background=dark
    let g:solarized_termtrans = 1
    colorscheme solarized
    

    Update: According to Jim Stewart, this works on Kitty too.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-07 08:01

    I struggled with the same problem on OSX 10.11.6, iTerm2 Build 3.0.12.

    Here is my fix for it.

    1. .vimrc

      syntax enable set background=dark colorscheme solarized

    2. Set Report Terminal Type to xterm-256color.

    1. Set color preset in the profile to Solarized Dark

    0 讨论(0)
提交回复
热议问题