Search code examples
vim

Is there a difference between hi and hi!, like hi Visual guibg=#FFEC8B and hi! Visual guibg=#FFEC8B


This is a simple question, and I'm only asking it here because I couldn't find the answer in Vim's help, under :h :hi. I have seen some people use hi and others use hi!, like hi Visual guibg=#FFEC8B vs hi! Visual guibg=#FFEC8B OR hi link CursorLineNr Visual vs hi! link CursorLineNr Visual. Is there a difference between them? From what I know, the bang ! symbol toggles a setting. But when I run them, I get the same results, whether I use hi or hi!.


Solution

  • In the form :hi! Group ctermbg=black, the ! nullifies the whole command, which makes it rather pointless.

    In the form :hi! link FromGroup ToGroup, the ! forces the link to be made even if FromGroup already has some attributes set.

    See :help :hi-link.