Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ad hoc text highlighting in vim

Tags:

vim

I'm doing a lot of digging around in log files these days, which usually involves tracking a certain identifier through various places in the log file. If I search for the identifier, then vim highlights all the occurrences, which really helps in the digging, but it disappears if I search for something else.

Is there a quick way to get vim to highlight, e.g., change the background or color, of text matching a certain regular expression?

I suppose syntax highlighting is sort of what I want, but it would be nice if there was a more dynamic way.

like image 795
David Norman Avatar asked Feb 09 '10 17:02

David Norman


1 Answers

The command Vim has available for that is :match. You can also use the matchadd() function to add an arbitrary number of matches.

like image 173
jamessan Avatar answered Sep 27 '22 19:09

jamessan