This one beats me after 30 years of vi/vim usage... Context: I'm on FreeBSD using the latest vim (7.4.796). A month or so ago, syntax highlighting in xterm(318) started acting up. In particular, the highlighting of comments is cyan, not the expected gray.
To track this down I have done the following.
Strip down my ~/.vimrc to these few lines
$ vim .vimrc
1 " Normal must be set before colors "fg" and "bg" can be used.
2 highlight Normal ctermfg=216 ctermbg=233
3
4 " gray This comment.
5 highlight Comment cterm=NONE ctermfg=250 ctermbg=bg
6
7 " Line numbers indicate this .vimrc was read.
8 set number
9 syntax enable
Note that the line numbers appear; color 250 is gray in my TERM=xterm-256color.
I have moved away my ~/.vim directory to avoid any local plugin interference.
Interestingly, when I :so .vimrc the correct color for the comments is used. It appears as if only the highlighting stuff is ignored upon startup, but works when sourced explicitly.
EDIT #1: I don't have any VIM environment variable set.
EDIT #2: :verbose hi Comment says
Comment xxx term=bold ctermfg=14 guifg=#80a0ff
Last set from /usr/local/share/vim/vim74/syntax/syncolor.vim
EDIT #3: :scriptnames says
1: ~/.vimrc
2: /usr/local/share/vim/vim74/syntax/syntax.vim
3: /usr/local/share/vim/vim74/syntax/synload.vim
4: /usr/local/share/vim/vim74/syntax/syncolor.vim
5: /usr/local/share/vim/vim74/filetype.vim
6: /usr/local/share/vim/vim74/plugin/getscriptPlugin.vim
7: /usr/local/share/vim/vim74/plugin/gzip.vim
8: /usr/local/share/vim/vim74/plugin/logiPat.vim
9: /usr/local/share/vim/vim74/plugin/matchparen.vim
10: /usr/local/share/vim/vim74/plugin/netrwPlugin.vim
11: /usr/local/share/vim/vim74/plugin/rrhelper.vim
12: /usr/local/share/vim/vim74/plugin/spellfile.vim
13: /usr/local/share/vim/vim74/plugin/tarPlugin.vim
14: /usr/local/share/vim/vim74/plugin/tohtml.vim
15: /usr/local/share/vim/vim74/plugin/vimballPlugin.vim
16: /usr/local/share/vim/vim74/plugin/zipPlugin.vim
Now I ran out of ideas what is going on here and how to fix it. Someone hit me with the clue bat, please.
highlightcommands to the bottom of thevimrcfile? – Karl Yngve Lervåg Jul 27 '15 at 20:16:verbose hi Commenttell you? – jjaderberg Jul 27 '15 at 21:16:scriptnamescommand is a script which loads that file. What does:echo colors_nametell you? – jjaderberg Jul 27 '15 at 21:28:helpgrep \ct_rbgmay tell you something about it.:verbose set bg?may tell you something, too. – garyjohn Jul 27 '15 at 21:45:syntax resetcommand has been run, and it has been run after your vimrc is loaded. That command involves sourcing thatsyncolor.vimfile and if you look at that you see a line that sets Comment to cyan when 'background' is 'dark'. What you see is a default but I'm not sure why the default is loaded after your vimrc. I can't pursue it now, but look at that file and you should be able to trace back when it is loaded and why. – jjaderberg Jul 27 '15 at 21:51