When using Vim is there a way that :grep
or :vimgrep
will color the patterns returned to the buffer?
Asked
Active
Viewed 3,893 times
10

Keith Pinson
- 7,835
- 7
- 61
- 104

Luis
- 1,828
- 2
- 19
- 27
4 Answers
4
If you search for the pattern after you've :vimgrep'd it, Vim will highlight it. Just edit the :vimgrep pattern files
into :g/pattern/
.
For a richer solution, try this script.

George V. Reilly
- 15,885
- 7
- 43
- 38
-
2Could you elaborate a bit more or provide an example for your suggestion? I do not fully understand what you mean with editing `:vimgrep pattern files` into `:g/pattern/`. – Wolfson May 20 '20 at 11:01
2
You can use the Unix grep:
:!grep --color pattern %
There may be other solutions using internal grep/vimgrep but this one works for me.

Taurus Olson
- 3,153
- 2
- 26
- 21
0
0
Two ways:
- For normal search
/
you can use:set hls
. - Or you can use
:match Search /pattern/
. This will hightlight everything that matchespattern
.

Peter Stuifzand
- 5,084
- 1
- 23
- 28