Loading ...
Sorry, an error occurred while loading the content.
 

Re: how to highlight a rectangle?

Expand Messages
  • Liu Yubao
    ... [snip] ... It appears it should be: . % . row_before . l . & . % . col_before . v
    Message 1 of 3 , Nov 28, 2006
      A.J.Mechelynck wrote:
      > Liu Yubao wrote:
      >> Hi,
      >>
      >> I want a function Highlight(from_row, from_col, width, height, color)
      >> where
      >> from_row > 0 && from_col > 0 && width >=0 && height >=0 and zero means
      >> maximum.
      >> The highlight will stay until I call something to cancel it.
      >>
      >> With this function, I can place a rule at column 80 with Highlight(1,
      >> 80, 1, 0, green),
      >> highlight all xml blocks like View Source Chart extension for Firefox
      >> (http://jennifermadden.com/scripts/ViewRenderedSource.html), make a
      >> table with colorized
      >> border and so on.
      >>
      >> I would greatly appreciate your help!
      >>
      >>

      [snip]

      > else
      > exe 'match' a:highlightGroup '/'
      > \ . '\%>' . row_before . 'l^.*$'
      > \ . '\&'
      > \ . '\%<' . row_after . 'l^.*$'
      > \ . '\&'
      > \ . '\%>' . col_before . 'v.*$'
      > \ . '\&'
      > \ . '^.*\%>' . col_after . 'v.'
      It appears it should be:
      \ . '\%>' . row_before . 'l'
      \ . '\&'
      \ . '\%<' . row_after . 'l'
      \ . '\&'
      \ . '\%>' . col_before . 'v'
      \ . '\&'
      \ . '\%<' . col_after . 'v'

      > \ . '/'
      > endif
      > endfunction
      >
      > Notes:
      > - The last argument is not a color but a highlight group, as in
      >
      > :exe 'call Highlight(1,80,1,' . (line('$') - 1) . ', Todo)'

      The last argument should be quoted with double quotation marks.

      It's a pity this function can only highlight text in a rectangle area,
      it can't highlight an empty area.

      Anyway, thank you very much, I learn the usage of "\%>" and "\%<".

      >
      > - Arguments which would not result in a nonempty highlight will be
      > rejected (except that there is no check that lines are long enough or
      > numerous enough to reach into the highlight area). In particular, height
      > or width cannot be zero. (Use some arbitrary high value like 999999 for
      > maximum height or width.)
      > - To remove the highlight, use
      >
      > :match none
      >
      > - The use of continuation lines assumes that 'nocompatible' has been
      > set, either explicitly, or implicitly due to the existence of a user vimrc.
      >
      > see
      > :help :match
      > :help ordinary-atom
      > :help pattern
      >
      >
      > Best regards,
      > Tony.
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.