How to remove highlighted background of text in vim?

Viewed 2697

I am referring to the grey background highlighting which is making vim unreadable. Note - I am running vim on Windows Subsystem for Linux. Also, this is not search highlighting. This is the default view every time I open Vim.

screenshot

It seems it has nothing to do with syntax highlighting. I created a new file named a.txt . On using :syn list , it said no syntax items defined for this buffer, but I still had grey background on every line. screenshot of a.txt

4 Answers

For anyone coming across this problem now, here is how I was able to fix this issue.

I first realized that what was happening is that the highlight group Normal was not being set for some reason from my theme. If, in the command line, I ran

:highlight Normal ctermfg=NONE

The highlighting would look normal.

The only problem being is that I had to run this after the buffer was entered, so traditional highlighting in the .vimrc was not working.

Adding

func! FixNormal()
    highlight Normal ctermfg=252
endfu
com! Normal call FixNormal()

Then above this function adding

au! BufEnter * Normal

The issue would resolve itself.

Explanation

The code creates a function that when called, does the same command that originally worked (highlighting Normal with None). The function is then called by the autocommand (au!) when the buffer is entered (BufEnter) and runs the function Normal.

I had grey text highlights that were caused by my current syntax highlighting file.

In this case, :syntax off did the trick

Related