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
To those who still have problem.
iTerm 2 -> Preferences -> Profiles -> Colors -> Minimum contrast -> lowest
In order to turn code highlighting on in vim, try to enable the syntax plugin:
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.
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: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: