For following snippet of code, to see what was highlighted I need to run :highlight LineHighlight ctermbg=darkgray guibg=drakgray after running vim session, and then rest of snippet works (i.e. loads which lines to highlight etc) , for some reason this one line is not picked up from .vimrc - any hint how to fix it highlight definition so I don't need to type it all over again in gVim ? (it works in Vim)

" define line highlight color
highlight LineHighlight ctermbg=darkgray guibg=darkgray

nnoremap <Leader>l :call matchadd('LineHighlight', '\%'.line('.').'l')<CR>
  • In Vim it just works! ([]+[l] highlights line)
  • In GVim I have to run :highlight LineHighlight ctermbg=darkgray guibg=darkgray to make highlights visible

2 Answers 2


you could try to add the following line

syntax on

before the line highlight LineHighlight ctermbg=darkgray guibg=darkgray.

to the .vimrc file.

This worked for me.


You probably need to add the highlight command to your gvimrc, since some things get reset when processing GUI startup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.