I use gvim as my text editor and the syntax coloring is great except it highlights "errors" and gives it a white background with red font. How do I turn off error highlighting? I find it annoying and don't need it.
How to turn off gvim error highlighting
gvimgvimrcsyntax highlightingvimvimrc
Related Solutions
There are two abstractions for syntax coloring in Vim. First, the syntax plugin provides definitions for the various syntax elements (e.g. an HTML tag name -> htmlTagName
), and links them to generic highlight groups (e.g. Statement
). A colorscheme then provides the actual attributes and colors for those (which can depend on whether you use GVIM or a terminal).
If you don't like the color / formatting of a particular highlight group, you'd basically create your own customized fork of the colorscheme. Copy the existing colors/schemename.vim
to ~/.vim/colors/newscheme.vim
, and use the new name in your .vimrc
via the :colorscheme newscheme
command.
On the other hand, if you're fine with the general colors, and just think that a particular syntax element should use a different group, you can override the default assignment. In this example:
:syntax link htmlTagName Constant
First, don't make any changes to the original syntax files! You'll regret this when you update your Vim.
If you need to make additions / adaptations, Vim has a mechanism for that. Just put the additional :syntax
commands into ~/.vim/after/syntax/htmldjango.vim
(note the use of the after directory), and it'll automatically be included by Vim.
If you don't need to parse any additional syntax, but just change the colors, that's done by the :hi
/ :HtmlHiLink
commands. As htmldjango.vim
is just an extension of html.vim
, those are found in the latter.
To change the colors, you need to find out which syntax group causes the highlighting. :syn list
shows all active groups, but it's easier when you install the SyntaxAttr.vim - Show syntax highlighting attributes of character under cursor plugin. When you have the name of the offending syntax group, you can redefine the highlighting, for example:
This is the original definition:
HtmlHiLink htmlTag Function
HtmlHiLink htmlEndTag Identifier
Apparently, your colorscheme (yet another abstraction) paints Function
yellow and Identifier
red. To override this just for HTML(Django), you'd pick another group from the plain :hi
command's output, choose e.g. Special
and then redefine via this:
hi link htmlTag Special
hi link htmlEndTag Special
You can put those into the mentioned ~/.vim/after/syntax/htmldjango.vim
, or also just into your ~/.vimrc
.
To remove all highlighting from a group, use :hi link htmlGroupHere NONE
.
Best Answer
The highlight of error messages is determined by the Error and/or ErrorMsg highlight groups. I'm not sure which one you're seeing, so you might as well disable both. You can see how each group is defined by executing, e.g.,
which will show you, in color, a line like this:
The easiest way to clear those settings is to execute
If you never set any colorschemes, I think you can just put those commands in your ~/.vimrc, after any
:filetype
,:syn
or:colorscheme
commands. If you change color schemes, you will need to do something like using autocommands to make sure those highlight groups are always clear, e.g.,The GuiEnter autocommands account for the behavior of Vim when invoked as gvim, which is to defer some color setting until after ~/.vimrc is read and the GUI is brought up.