iterm vim 颜色方案不起作用
当我在 iTerm 中从命令行运行 vim 时,语法突出显示似乎在本地不起作用。
例如,在 vim 中,我安装了一个很好的颜色方案,它在 MacVim 中运行得很好,但如果在 iTerm 中也能显示相同的颜色方案,那就太好了。
我有什么想法可以打开它吗?
这是我尝试使用的配色方案 http://www.vim.org/scripts/script.php?script_id=2340
When I run vim from the command line in iTerm, syntax highlighting doesn't seem to work locally.
In vim for example I have installed a nice colorscheme that works quite well in MacVim but it would be great if in iTerm it showed the same one.
Any ideas how I can turn this on?
This is the color scheme I'm trying to use
http://www.vim.org/scripts/script.php?script_id=2340
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
为了在 vim 中打开代码高亮,请尝试启用语法插件:
In order to turn code highlighting on in vim, try to enable the syntax plugin:
该配色方案看起来只支持 256 色终端。如果 Vim 认为您的终端仅支持 8 种颜色,您将不会看到该特定的配色方案。
您可以通过以下方式在 Vim 中检查这一点:
如果返回
8
,则可能是问题所在。尝试在~/.vimrc
中将其设置为 256,看看是否有帮助:That color scheme looks like it only supports 256-color terminals. If Vim thinks that your terminal only supports 8 colors, you won't see that specific color scheme.
You can check this in Vim by:
If that returns
8
, this might be the problem. Try setting it to 256 in your~/.vimrc
and see if that helps:对于那些仍然有问题的人。
i学期 2 ->首选项->个人资料 ->颜色 ->最小对比度->最低
To those who still have problem.
iTerm 2 -> Preferences -> Profiles -> Colors -> Minimum contrast -> lowest
我以前遇到过这个问题,以及一些相关的问题,所以我将总结一下我发现的内容。
确保 iTerm 设置为使用 256 色。在命令行尝试
$ echo $TERM
,如果没有看到xterm-256color
,请按照说明操作 在此答案中。设置您的
vimrc
来处理其他终端。例如,Snow Leopard 中的常规终端仅支持 8 种颜色,如果您尝试使用 256 色配色方案,则会闪烁(在这种情况下我只是不设置一种颜色)。这是我所拥有的:I've had this problem before, as well as some related issues, so I'll summarize what I found.
Make sure iTerm is set to use 256 colors. Try
$ echo $TERM
at the command line, and if you don't seexterm-256color
then follow the directions in this answer.Set up your
vimrc
to handle other terminals as well. The regular Terminal in Snow Leopard only supports 8 colors for instance and will blink if you try to use a 256 color color scheme (I just don't set one in that case). Here's what I have:在尝试了这里所有其他答案之后,我最后需要的是:
After trying all the other answers here, the final thing I needed was:
尽管遵循了这个(以及其他类似)问题中的所有建议,但我最终在几年前从网络上的某个地方获取的 vimrc 的一个被遗忘的部分中发现了我的麻烦(因为它组织得相当好),然后进行了广泛的修改为了我自己的目的。
但问题区域出在我从未接触过的一小部分设置中,回到我开始使用的原始文件中。 .vimrc 的相关部分是:
毫不奇怪(回想起来),“set term”行会重置一些东西,这样无论你的终端在 TERM 环境变量中报告什么类型,你最终都会得到一个通用的 8 色 ANSI终端。在 .vimrc 中显式设置 'term' 可能是一个非常糟糕的主意,就像直接设置 t_Co 一样。
我删除了整个块(并将 gvim 设置放入它们所属的 .gvimrc 中),从那时起,一切都对我来说正常工作。
Despite following all the advice in this (and other, similar) questions, I eventually found my trouble in a forgotten part of a vimrc I had taken from somewhere on the web years ago (because it was rather nicely organised), and then extensively modified for my own purposes.
But the problem area was in a little group of settings that I had never touched, back in the original file I started with. The relevant bit of the .vimrc was:
Unsurprisingly (in retrospect), that "set term" line resets things so that regardless of what type your terminal is reporting in the TERM environment variable, you wind up with a generic, 8-color ANSI terminal. Setting 'term' explicitly inside the .vimrc is probably a very bad idea, just like setting t_Co directly.
I removed this whole block (And put the gvim settings into .gvimrc, where they belong), and everything has been working correctly for me ever since.
编辑 sudo vim ~/.vimrc 并添加“语法”应该可以解决问题。
Edit sudo vim ~/.vimrc and add "syntax on" should fix issue.