-1

I have tried to change the background color in Vim the way suggested by the accepted answer here but it does not work for me.

What is wrong? (This is in the Ubuntu subsystem in Windows 10).

Leo
  • 4,136
  • 6
  • 48
  • 72
  • 2
    Well, the snippet in your title is a) not the same as in the linked answer, and b) incorrect anyway, so you can't really expect it to behave the same. What exactly did you add to your `vimrc`? – romainl Feb 19 '21 at 18:07
  • Additionally, the colon is for when you run the command interactively. In your `.vimrc`, leave out the colon. Again, it would help a lot if you showed us the actual contents of your `.vimrc`, and maybe where you saved it, too. – joanis Feb 19 '21 at 18:45
  • @romainl The snippet without the colon, of course. – Leo Feb 20 '21 at 12:11
  • @joanis It is in ~/.vimrc and the other parts of the file works ok (like setting the colorscheme etc). – Leo Feb 20 '21 at 12:12
  • @romainl Ah, yes. I got the title wrong here. But it is correct in my .vimrc – Leo Feb 20 '21 at 12:14
  • Hm, sorry. I use /usr/share/vim/vimrc because of some confusions about ~/.vimrc in ubuntu/bash. – Leo Feb 20 '21 at 12:24
  • Looking at it again I can see there is something more strange going on. If I place the command in "~/.vimrc" it works, but if I place it in "/usr/share/vim/vimrc" it does not work (but setting color scheme work). – Leo Feb 20 '21 at 12:39
  • Ah, I give up. Too many bugs in this area. (All default color schemes does not work correctly either.) – Leo Feb 20 '21 at 12:49

1 Answers1

1

Adding the following to your vimrc before any colorscheme command should paint every character belonging to the Normal highlight group with a yellow background, no matter what colorscheme you use:

" On Windows: %userprofile%\_vimrc
"         or: %userprofile%\vimfiles\vimrc
"    On Unix: $HOME/.vimrc
"         or: $HOME/.vim/vimrc
augroup MyColorSchemeOverrides
    autocmd!
    autocmd ColorScheme * highlight Normal ctermbg=yellow
augroup END

Here is a gist of mine that explains the hows and whys of overriding colorschemes in Vim.

romainl
  • 186,200
  • 21
  • 280
  • 313