One can change the search color of search terms with the Search highlight scheme. Similarly one can change the color of a line in the quickfix window with QuickFixLine.

However, how does one change the colour of the search phrase within listing in the quick fix window?

A picture is worth 1000 word, hence in the following image, I :vimgrep searched for 'buffer', and I underlined some matches in yellow with a screen grab tool, is it possible to highlight them in vim (in particular Neovim)?: enter image description here

2 Answers 2


Two ideas:

  1. If you just want to highlight them, search with /buffer and make sure hlsearch is on. Or, for a more permanent solution, navigate to the quickfix window and use :match Search /buffer/
  2. If you care more about filtering, I would do :packadd cfilter, which provides the :Cfilter command. Then a :Cfilter /buffer/ gives you only entries with buffer, and :colder restores the original. (Of course, given that the original search was buffer, OP won't be able to limit in this way.)
  • Searching within the quick fix window does make it highlight. But then one has to type the search term twice. I wonder if there is anyway to make it automatically search for it upon opening the quickfix window. Apr 11, 2020 at 16:42

Use an AutoCommand.

See :help QuickFixCmdPost and :help QuickFixCmdPost-example.

QuickFixCmdPost         Like QuickFixCmdPre, but after a quickfix
                        command is run, before jumping to the first
                        location. For |:cfile| and |:lfile| commands
                        it is run after the error file is read and
                        before moving to the first error.
                        See |QuickFixCmdPost-example|.

Also, from :help CTRL-W_<Enter>:

When the quickfix window has been filled, two autocommand events are triggered. First the 'filetype' option is set to "qf", which triggers the FileType event (also see |qf.vim|). Then the BufReadPost event is triggered, using "quickfix" for the buffer name. This can be used to perform some action on the listed errors. Example:

au BufReadPost quickfix  setlocal modifiable
    \ | silent exe 'g/^/s//\=line(".") .. " "/'
    \ | setlocal nomodifiable

This prepends the line number to each line. Note the use of "=" in the substitute string of the ":s" command, which is used to evaluate an expression. The BufWinEnter event is also triggered, again using "quickfix" for the buffer name.

In your function, use getmatches() to extract the last one and execute :match on that string. Once you get it working, edit my answer to provide a workable script and delete this sentence. :)

Your Answer

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

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