Here’s a question from Mr. Rajan, one of the regular reader at Techglimpse. His issue is why
vim highlights texts in red?
I’m seeing a strange behavior of vim editor that highlights all texts in red color and it happens only when
/etc/sysconfig/namedfile is opened. Here’s the screenshot of the issue. I’m able to edit the file, save and do all vim operations without any issue, but still the red texts is really annoying. How to get rid of this?
Why vim highlights text in Red?
Hi Rajan, I tried to replicate the issue in Techglimpse lab, but couldn’t reproduce the same. However, there’s a reason for
vim highlighting texts in red color. Generally,
vim has plugins to understand the syntax of programming languages and certain configuration files. For example, vim can understand comments and highlight those texts in blue color and variables in green etc…Similarly errors are generally highlighted in red color and it looks like
vim does not know how syntax should be handled for
However, highlighting of error messages is done with the help of
ErrorMsg highlight groups. So try highlight groups as shown below.
Step 1: Open the file and type the below in last-line mode (ESC & semi-colon).
Vim will display the values set for
Error highlight group as shown below:
Error xxx term=reverse cterm=bold ctermfg=7 ctermbg=1 guifg=White guibg=Red
:verbose hi Error Error xxx term=reverse cterm=bold ctermfg=7 ctermbg=1 guifg=White guibg=Red Last set from /usr/share/vim/vim74/syntax/syncolor.vim
guifg & guibg, which stands for GUI foreground and GUI background respectively.
Step 2: To stop
vim using Error groups, type:
:hi Error NONE
Still seeing red texts? Then you may have to disable
ErrorMsg as well.
:hi ErrorMsg NONE
Hope it helps.
:hi Error NONE inside the
vim editor is only a temporary solution. If you ever want to disable Error highlight for every file type, then you need to set the same in
~/.vimrc as shown below:
au ColorScheme * hi Error NONE au ColorScheme * hi ErrorMsg NONE au GuiEnter * hi Error NONE au GuiEnter * hi ErrorMsg NONE