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

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

Expand Messages
  • Barry Arthur
    Mar 22, 2013
    • 0 Attachment
      Ooops! Good catch. I think this fixes it:

      diff --git a/plugin/SearchParty.vim b/plugin/SearchParty.vim
      index 373ffd3..2b194f7 100644
      --- a/plugin/SearchParty.vim
      +++ b/plugin/SearchParty.vim
      @@ -282,7 +282,7 @@ function! PrintWithHighlighting() range
       
           let ms = match(line, @/)
           let me = matchend(line, @/)
      -    while ms != -1
      +    while ms != -1 && ms != me
             echohl none
             echon strpart(line, 0, ms)
             echohl Search



      On 22 March 2013 15:03, Christian Brabandt <cblists@...> wrote:
      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 a topic in the Google Groups "vim_dev" group.
      To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_dev/V2vGo2CcHqU/unsubscribe?hl=en.
      To unsubscribe from this group and all its topics, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.



      --
      --
      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