I'm finally getting around to upgrading from Vim 7.4 to Vim 8.1, but my global custom highlight colors have stopped working.
I am aware similar questions (such as this one) have been asked, but these all seem to be related to the closed Issue #542, and none of the solutions there seem to work for me.
8.1 from the jonathonf/vim ppa repository on Ubuntu 18.04.
VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 22 2018 11:42:48) Included patches: 1-346 Modified by firstname.lastname@example.org
--version text (Pastebin link)
I also tried Vim 8.0 from Ubuntu 18.04's
Minimum steps to reproduce
Create the following
echo "Read the correct vimrc" hi Comment ctermfg=green cterm=none
Edit any file with comments; "Read the correct vimrc" is displayed, but the comment color is not green.
Additionally, sometimes I can see the color change a few milliseconds after the file is opened, suggesting something may indeed be overriding my settings.
:hi Comment ... from within vim works as expected.
-u .vimrc does not make a difference.
Other things I've tried
I've tried using the
autocmd suggestion from the above linked answer, to no avail. In short, that looks something like this:
augroup customhighlight autocmd! autocmd ColorScheme * hi Comment ctermfg=green augroup end
I then went down the rabbit hole of vimrc defaults:
system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" 2nd user vimrc file: "~/.vim/vimrc" user exrc file: "$HOME/.exrc" defaults file: "$VIMRUNTIME/defaults.vim" fall-back for $VIM: "/usr/share/vim"
Unfortunately, unless I missed something, there doesn't appear to be anything in the default/Debian vim defaults that would override a user
.vimrc, and, indeed, that would be silly.
I have not gone down the route of implementing custom color schemes, which was another suggestion. Reason being, I work with a lot of different filetypes on a regular basis, and there has always been a way to globally customize colors, so I'm hoping there's a solution.
:verbose hi Comment reports:
Comment xxx term=bold ctermfg=14 guifg=#80a0ff Last set from /usr/share/vim/vim81/syntax/syncolor.vim
What is the best practice to set global syntax highlight color preferences in Vim 8.x?
verbose hi Comment?
:verbose hi Comment. That should tell you where the Comment highlighting was last set. You might also execute
:au ColorSchemeto see if there are any other ColorScheme autocommands that might be overriding yours.
syntax oncould be the culprit. Is your custom highlight before or after that line in your vimrc ?