3

My colour scheme (morning) doesn't play nice with the quickfix window: I cannot read the selected item's location, because the foreground and background colours are the same. Because of this I want to redefine some highlighting styles, e.g. for Search and LineNr. However, I only want to do this in the quickfix window.

When I edit ~/.vim/syntax/qf.vim with my changes, this affects also highlighting in other syntaxes. How can I change highlighting styles for one syntax only? I'm using, for example:

hi Search ctermbg=white
  • May not help but I had some specific colors I wanted in help and text files so I defined my own in help.vim syn match myhelpComment " awk \| gawk \| sed " and put the color definition in syncolor.vim.SynColor myhelpComment gui=bold guifg=#000000 guibg=Azure. Probably not the most elegant but it works – Steve Feb 11 at 22:23
1

I'm afraid the solution you suggest isn't possible. Vim's highlighting and colorscheme commands are global: any colours you set are set everywhere.

The best you could do is to change the colours everywhere when the quickfix window opens and then change them back when it closes, (or perhaps change them when entering the buffer and change them back when you leave it), but there is no way of having different highlighting applying in different windows simultaneously.

However, this shouldn't prevent you from fixing the root problem. The quickfix window uses several colours that are separate from any other syntax colouring (QuickFixLine, qfLine, qfError etc.) so you should be able to resolve any such visibility issues by using these rather than changing Search as you suggest.

If you are still experiencing this issue (I realise your question is almost 4 years old now) then if you could add a few more details about exactly what the problem is in the quickfix, I'm sure we could help you solve it.

| improve this answer | |
0

You can use auto commands and put them in ~/.vimrc.

au QuickFixCmdPre * hi Search ctermbg=white

This command will set ctermbg color as White before entering quickfix.

| improve this answer | |
  • This doesn't seem to work. I'm using syntastic, maybe that matters? – user2598 May 31 '16 at 5:57
  • Can you give :verbose hi Search in command line? So that we can check whether the color is changed by syntactic or any other plugin? – SibiCoder May 31 '16 at 6:26
  • It says Last set from /usr/share/vim/vim74/colors/morning.vim; the command doesn't seem to be called at all. – user2598 May 31 '16 at 11:39
  • Can you put the auto command line in a plugin inside after directory? This plugin may be created like /home/username/.vim/after/plugin/pluginname.vim if you don't have this yet. That might work. – SibiCoder May 31 '16 at 12:10
  • I tried, but the result is the same, unfortunately. – user2598 May 31 '16 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy