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

68808Re: Suggestion: Highlight the search pattern in :g/.../# or :g/.../p

Expand Messages
  • Christian Brabandt
    Mar 22, 2013
    • 0 Attachment
      Hi Barry!

      On Fr, 22 Mär 2013, Barry Arthur wrote:

      > The final version I added to SearchParty:
      >
      > function! PrintWithHighlighting() range
      > let lnum = a:firstline
      > let lnum_len = len(line('$'))
      > for line in getline(a:firstline, a:lastline)
      > echohl LineNr
      > echon printf("%*s ", lnum_len, lnum)
      > echohl none
      > let lnum += 1
      >
      > let ms = match(line, @/)
      > let me = matchend(line, @/)
      > while ms != -1
      > echohl none
      > echon strpart(line, 0, ms)
      > echohl Search
      > echon strpart(line, ms, me - ms)
      > echohl none
      > let line = strpart(line, me)
      > let ms = match(line, @/)
      > let me = matchend(line, @/)
      > endwhile
      > echon line . "\n"
      > endfor
      > endfunction
      >
      > command! -range P <line1>,<line2>call PrintWithHighlighting()

      I think, you might be getting problems, if your pattern match is
      zero-width, e.g. searching for :g/^/P might not work correctly.

      regards,
      Christian
      --

      --
      --
      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.
    • Show all 13 messages in this topic