11

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.

1 Answer 1

12

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.,

:hi Error

which will show you, in color, a line like this:

Error          xxx term=reverse cterm=bold ctermfg=7 ctermbg=1 guifg=White guibg=Red

The easiest way to clear those settings is to execute

:hi Error NONE
:hi ErrorMsg NONE

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.,

au ColorScheme * hi Error NONE
au ColorScheme * hi ErrorMsg NONE
au GuiEnter * hi Error NONE
au GuiEnter * hi ErrorMsg NONE

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.

5
  • Hm.. okay i'm using slate and when I open a .html file and type in still like {% it highlights it in while and gives it red font. That's error highlighting right? or is it something else? because I tried putting both the au slate hi Error NONE and au slate hi Error NONE commands as well as the hi Error NONE and hi ErrorMsg NONE in my .vimrc file and the white highlighting with red font is still showing up in my .html files :/ Commented Oct 6, 2013 at 2:24
  • I see that. I fixed an error in my answer, but it's not enough. I'll do some more testing and get back to you in a bit.
    – garyjohn
    Commented Oct 6, 2013 at 3:04
  • I didn't think it was going to be so hard to kill a color. I forgot that gvim (as opposed to terminal vim) waits to set its highlight colors until after the GUI is brought up, which is after ~/.vimrc is read. Try adding those GuiEnter autocommands and see if that helps.
    – garyjohn
    Commented Oct 6, 2013 at 3:23
  • hm, it still didn't work for some reason, the highlights are still there. Maybe what I'm looking at isn't an error? I opened a .html file using gvim and when I write stuff like {%, it highlights it in white and makes the font color red.. that's error highlighting right? Commented Oct 7, 2013 at 2:56
  • That is the Error highlighting, but it could also be some other highlight group with the same colors. Execute :help synID() and scroll to the bottom of that entry. There you will find a command that echoes the name of the highlight group under the cursor. When I open gvim, execute :e foo.html, and insert a >, the > is colored white on red. Executing that synID() command prints htmlError and executing :hi htmlError prints htmlError xxx links to Error. If you're seeing the same results, and the error is still white on red, try :verbose hi Error which shows where it was last set.
    – garyjohn
    Commented Oct 7, 2013 at 5:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .