When I grep inside emacs, it begins to be completelly laggy when lines are too long (just try to grep in your home emacs directory and you will see what I mean). How to set limit to line lengths in grep output buffer?
The effect can be reproduced with the following emacs lisp form. One can run the code in the scratch buffer.
(let ((file (make-temp-file "greptest")))
(with-temp-file file
(dotimes (i 100)
(dotimes (j 100)
(dotimes (k 100)
(insert (string (+ 32 (random (- 127 32))))))
(insert "test"))
(insert "\n")))
(grep (concat "grep --color -nH --text -e test " file))
file)
It is clear that the effect depends on the performance of the computer. So it might be that you need to play around with the numbers to see the lagging.
-oE
is that it highlights also the surrounding characters. That might be acceptable.