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

Re: heighlighting ranges in buffer

Expand Messages
  • Nathan Hüsken
    ... Ok, you got me confused there. I thought col was supposed to be the byte offset in the buffer. Got it corrected and it works like a charm. Thanks! -- --
    Message 1 of 5 , Feb 14, 2013
    • 0 Attachment
      Am Donnerstag, 14. Februar 2013 11:13:36 UTC+1 schrieb Nathan Hüsken:
      > Am Donnerstag, 14. Februar 2013 04:46:04 UTC+1 schrieb ZyX:
      > > If I correctly understood OP, current symbol != all words that are the same as the one under cursor (i.e. local variable in one function is different symbol from the local variable in another function, even if it has the same name).
      >
      > That is correct.
      >
      > > Thus what is needed, given positions in a list of three-tuples of (lnum, col, len) is constructing the regex like this:
      > >
      > > let regex='\v'.join(map(copy(positions), '"%".v:val[0]."l%".v:val[1]."c.{".v:val[3]."}"'), '|')
      > > . This assumes length is given it terms of characters, but column is byte offset. Then this regex may be used in your function.
      >
      > Ok, I have (line,col) but I convert it to byte offset using line2byte(line) + col.
      >
      > Unfortantly something does not work. The regex I get is:
      >
      > \v%1l%164c.{5}|%1l%234c.{5}|%1l%332c.{5}
      >
      > now I put this into:
      >
      > let w:matchid = matchadd('AutomaticWord',regex, -1)
      >
      > But the positions are not highlighted.
      >
      > Thanks!
      > Nathan

      Ok, you got me confused there. I thought col was supposed to be the byte offset in the buffer.
      Got it corrected and it works like a charm. Thanks!

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    Your message has been successfully submitted and would be delivered to recipients shortly.