Grimoire-
Command
.es

GNU+Linux command memo

vim : multiple search colors

Surligner plusieurs recherches en parallèle dans vim et de plusieurs couleurs.

/pattern1\|pattern2 (1)
:match Pmenu /pattern2/ (2)
:2match Error /pattern3/ (3)
:3match MatchParen /pattern4/ (3)
1 A vim search pattern here is a kind of regular expression, so you can highlight different words with a single pattern, but the color will be the same for each match
2 With the match command you can highlight other patterns with different colors. The first parameter of the command is the highlight-group to use, it’s part of the syntax highlighting mechanism of vim and it specifies the color that will be given to your matchs (to see all available groups type :highlight) here I chose Pmenu it’s a pink for me.
3 To add another group, you can use the commands : 2match and 3match with other hightlight-group names, here I chose Error (red) and MatchParen (turquoise). If you have a valide usecase with a need for more than 4 highlight colors, I would be happy to discover it.