I have several highlight commands in my .vimrc file. In Vim 7.3, these took effect immediately after Vim had started. After updating to Vim 7.4, this is not the case anymore. Vim uses its default highlighting initially. When I load .vimrc a second time by executing source ~/.vimrc, highlighting works as I want.
You should be able to reproduce this problem using the following steps:
Make a copy of your
.vimrcfile.Replace
~/.vimrcwith a file that contains just the linehighlight Type ctermfg=28 cterm=bold.Run
vim dummy.cin a 256 color terminal (for example GNOME Terminal).Type
intinto the buffer. Theintshould appear in regular font and be colored light green, which is not what I want.Enter
:source ~/.vimrc. Now theintshould appear in bold font and be colored dark green.
According to the article How to control/configure vim colors, it should be okay to just put the highlight commands into .vimrc. The article says that you should put syntax enable after the highlight commands, but this did not make any difference.
My first fix was to prepend each highlight command in .vimrc with autocmd VimEnter *. This worked for some file types, but not for others (C files are an example).
What is the reason for this behavior? How can I have the highlight commands executed when Vim is started such that they take effect for all buffers during the whole Vim session?
set compatibleat the beginning of.vimrc, syntax highlighting works as expected. So this really seems to be this bug in action. – Wolfgang Jeltsch Oct 25 '16 at 10:43highlightcommands withautocmd ColorScheme *, which was proposed as a workaround in the bug report. It still does not work. ☹ – Wolfgang Jeltsch Oct 25 '16 at 10:50hiaftercolo: https://vi.stackexchange.com/a/19910/9598 – sjas Sep 23 '20 at 09:19