使用Solarized的iTerm2中vim的颜色不正确 [英] Incorrect colors with vim in iTerm2 using Solarized

查看:299
本文介绍了使用Solarized的iTerm2中vim的颜色不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在终端vim(非gui)和日光化配色方案中遇到iTerm2的奇怪问题.首先,我将iTerm2设置为使用深色的日晒配色方案.

我也在用visolated做vim.我的.vimrc中有以下几行

set background=dark
colorscheme solarized

在终端中,配色方案看起来不正确:

作为参考,这是在MacVim(gui vim)下的外观

我需要在iTerm或.vimrc中进行哪些更改才能在控制台vim中正确显示颜色?

解决方案

要检查的几件事:

  1. 在iTerm2中的首选项"->配置文件"->终端"中,在终端仿真"下,将报告终端类型:"设置为xterm-256color.

  2. .vimrc中,您可以设置一些选项来确保它使用256色: 并且其中一个应该起作用,但首先是#1.

但是,如果使用的是默认的内置在Snow Leopard上的vim,它将无法正常工作,因为它不支持256色.我相信Lion的内置版本可以.

编辑:基于对此答案的几点评论,我从上面的.vimrc示例中删除了let g:solarized_termcolors = 256行.对于某些人来说,这似乎是个问题.另一个人说,添加let g:solarized_termcolors = 16行可解决彩色显示问题.您自己的里程可能会有所不同.

第二次:如果您将日晒调色板加载到iTerm2中,则必须let g:solarized_termcolors=16.如果您不是不是使用日晒调色板作为iTerm2颜色预设,则只有let g:solarized_termcolors=256.

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.

I am also using solarized for vim. I have the following lines in my .vimrc

set background=dark
colorscheme solarized

In the terminal the color scheme looks incorrect:

For reference this is how it looks under MacVim (gui vim)

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

解决方案

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.

这篇关于使用Solarized的iTerm2中vim的颜色不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆