Wrong colors using vim in iTerm2 using Solarized

I have a strange problem with iTerm2, in a vim (non-gui) terminal and a solarized color scheme. First, I installed iTerm2 to use a dark solar circuit.

I also use solarization for vim. I have the following lines in my .vimrc

set background=dark colorscheme solarized 

In the terminal, the color scheme looks incorrect: console vim

For reference, it looks like this in MacVim (gui vim) gui vim

What do I need to change in iTerm or my .vimrc to get the correct colors in my vim console?

+75
vim color-scheme iterm macos
02 Sep '11 at 1:00
source share
9 answers

A few things to check:

  • In iTerm2, in the settings → Profiles → Terminal in the “Terminal Emulation” section, you have “Report Terminal Type:” installed on xterm-256color.

  • There are some options in your .vimrc that you can also set to make sure it uses 256 colors:

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

BUT, if you use the standard version built into vim on Snow Leopard, it will not work, because it is not built with support for 256 colors. I believe the built-in version in Lion does.

Edit: Based on a few comments on this answer, I removed the line let g:solarized_termcolors = 256 from the .vimrc example above. This may seem to be a problem for some. Another says adding the line let g:solarized_termcolors = 16 fixes the color rendering problem. Your own mileage may vary.

Second edit: If you loaded the solar palette into iTerm2, you should let g:solarized_termcolors=16 . Only let g:solarized_termcolors=256 if you are not using the solar palette as the predefined color of iTarm2.

+113
Sep 02 2018-11-11T00:
source share

The above answers did not help me.

I am using iTerm2 with vim 7.3 on OS X 10.7.4.

If the above solutions did not work for you, try this

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

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

+84
Oct 19 '12 at 7:23
source share

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

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

Open iTerm 2, open Settings, click the Profiles icon (formerly Addresses, previously bookmarks) in the settings panel, then select the Colors tab. Click "Download Settings" and select "Import ...". Select the Solarized Light or Dark theme file.

You have now loaded the predefined Solarized color settings in iTerm 2, but you haven’t applied them yet. 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 setting from the Download Preset Download.

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

Or:

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

Edit .vimrc

Dark theme:

 syntax enable set background=dark colorscheme solarized 

Shine

 syntax enable set background=light colorscheme solarized 
+11
Mar 05 '14 at 23:51
source share

This worked for me in OS X 10.9.1 in iTerm 2, as well as in the terminal. One mistake I made was to put a colorscheme declaration before the termtrans and termcolors parameters (and I needed both to make them work). As others said, I set my terminal type to xterm-256color

 if !has("gui_running") let g:solarized_termtrans=1 let g:solarized_termcolors=256 endif colorscheme solarized set background=dark 
+8
Feb 12 '14 at 1:59
source share

From the creator: http://ethanschoonover.com/solarized/vim-colors-solarized

IMPORTANT NOTE TO TERMINAL USERS:

If you intend to use Solarized in terminal mode (i.e. not in a GUI version such as gvim or macvim), please consider setting up terminal emulators for use in the Solarized palette. Ive included palettes for some popular terminal emulator, as well as Xdefaults in the official Solarized download, available from the Solarized homepage. If you use Solarized without these colors, Solarized will need to be said to reduce its color scheme to a set that is compatible with the limited terminal palette of 256 (whereas using the color values ​​of 16 ansi pins you can set the correct specific values ​​for the Solarized palette).

If you use custom terminal colors, solarized.vim should work out of the box for you. If you are using a terminal emulator that supports 256 colors and do not want to use custom Solarized colors, you will need to use degraded 256 colors. To do this, simply add the following line before the colors in the solar line:

let g:solarized_termcolors=256

Again, I recommend simply changing the colors of the terminals to Solarized values ​​either manually or through one of the many terminal schemes available for import.

+6
Dec 09 '13 at 0:30
source share

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

This should lead to the fact that the vim colors in iTerm2 will be the same as in graphic editors.

+4
20 Sep
source share

I struggled with the same issue in OSX 10.11.6, iTerm2 Build 3.0.12.

Here is my fix for it.

  • .vimrc

    syntax set background = dark colorscheme solarized

  • Set the terminal type of the report to xterm-256color .

enter image description here

  1. Set the color setting in the profile for Solarized Dark.

enter image description here

+2
Nov 21 '16 at 19:25
source share

A simple way to solve this problem is:

In the colors located on vim-color-solarized, there is an arch called "solarozed.vim"

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

replaced by:
exe "let s: bg_back = '" .s: vmode. "bg =". s: none. "'"

+1
Mar 21 '15 at 12:40
source share

I tried all the previous sentences. I just added set t_Co=256 to .vimrc and it has been fixed. I did not need to create a tmux alias or modify the configuration file.

0
Aug 05 '17 at 22:10
source share



All Articles