Mohsin wrote:
I already tried your solution, it only works for a single region at a time
On applying the same higlighting to second region and the first one is
un-highlighted.

Try this (the third command will unhilight the first region):

  :highlight User1 term=bold cterm=5 guibg=red
  match User1 /\%>54l.\%<78l\&\%>14v.\%<39v/
  match User1 /\%>84l.\%<88l\&\%>14v.\%<39v/

- mohsin.

In Vim 7, you can have up to three matches (using :match, :2match and :3match). Note, however, that :3match is used by the matchparen plugin when the cursor is on a bracket, to show you its mate. Or, to highlight the matches in a single colour, you could concatenate the patterns with \| (meaning "or"):

  :match User1 /\%>54l.\%<78l\&\%>14v.\%<39v\|\%>84l.\%<88l\&\%>14v.\%<39v/

(one long line). If this becomes too long to look at easily in a script, you can use continuation lines (if 'nocompatible' is set):

        exec 'match User1 /'
          \ . '\%>54l.\%<78l\&\%>14v.\%<39v\|'
          \ . '\%>84l.\%<88l\&\%>14v.\%<39v/'

or even "simplify" the expression logically:

  :match User1 /\%(\%>54l.\%<78l\|\%>84l.\%<88l\)\&\%>14v.\%<39v/

Note the use of single quotes because the \ has special maning inside double quotes.

see ":help pattern.txt"


Best regards,
Yony.

Reply via email to