Mohsin wrote:
Is it possible to display (highlight) matches for /Word
simultaneously in 3 different colors:
1. Word .. hlsearch
2. \<Word\> .. hlsearchword
3. (?i)word .. hlsearchicase
how hard would it be? I don't want to use script to it.
thanks,
mohsin.
Maybe you can do the following (untested):
:map <Bslash>/ :match DiffAdd /<Bslash><lt><C-R>/<Bslash><gt>/<CR>
:map <Bslash>? :2match DiffChange /<Bslash>c<C-R>//<CR>
- Search normally for case 1.
- Hit \/ to highlight the latest search in DiffAdd colours (by default in
gvim: black on pale cyan) but only when present as a full word (case 2).
- Hit \? to highlight the latest search in DiffChange highlight (black on pale
magenta) regardless of case (case 3).
- Hit \/ or \? again to update the highlights. Type ":match none" or ":2match
none" to clear them.
- Change the highlight group names if you want different colours.
If, to you, this is already "script", then you would need to hack the C source
to get the desired result "without script"; but I wouldn't recommend it for
something this trivial, which can be accomplished by a couple of mappings or
(in a less obvious way) by using self-modifying mappings (map / to change the
way we search and, in the mapping, cmap <CR> to both finalize the first
mapping and unmap the second one...).
Best regards,
Tony.