On Apr 1, 2014 10:44 PM, "Ethan Hereth" <advocateddrummer@gmail.com> wrote:
>
> Ethan Alan
>
>
> On Tue, Apr 1, 2014 at 1:54 PM, <meino.cramer@gmx.de> wrote:
> > John Beckett <johnb.beckett@gmail.com> [14-04-01 17:28]:
> >> meino wrote:
> >> > I often use a search'n'replace on an area, which is limited by
> >> > a previously selected visual block.
> >> > Additional hlsearch is on by default.
> >> > After the searech'n'replace has ended, the found places are
> >> > marked all over the whole text.
> >> > This is often irritating to me.
> >> > Is there a way to limit the highlights set by hlsearch to
> >> > those place of the visual block area?
> >>
> >> As the other reply said, map a key to turn highlights off. See:
> >> http://vim.wikia.com/wiki/Highlight_all_search_pattern_matches
> >>
> >> However, while not really helpful for what you asked, it is
> >> possible to limit highlights to the last visually selected
> >> block. See:
> >> http://vim.wikia.com/wiki/Search_and_replace_in_a_visual_selection
> >>
> >> For example, consider these two searches:
> >> /[abc]
> >> /\%V[abc]
> >>
> >> The first finds all a or b or c, everywhere.
> >>
> >> The second finds the same, but only in the last visual
> >> selection (what would be highlighted if gv were used).
> >>
> >> John
> >>
> >>
> >>
> > Hi John,
> >
> > thanks for your reply!
> > I want to 'search and replace' not only to search.
>
> If I understand correctly, using /\%V in addition to '<,'> allows you
> to search-and-replace ONLY in the visually selected area. This could
> be handy if you have block selected (ctrl-v) a bit of text and want to
> search-and-replace ONLY in that visually selected text. I.e.
> '<,'>s/foo/bar/g will replace foo with bar anywhere in the lines
> containing the visual selection, whereas '<,'>s/\%Vfoo/bar/g will
> replace foo with bar ONLY in the region of text visually selected.
Not correct. It will replace foo with bar ONLY if *f* is in the region of visually selected text. Position of next letter (o) may be outside of the selection. \%V is zero-width match atom, not a regex modifier (there are some that control behavior of the whole pattern or the whole portion of the pattern that follows the modifier).
>
> To address your original question, it appears as if, at least on my
> machine with my configuration, that using the \%V variant of this
> search-and-replace the text will also only be highlighted in that
> visual selection, so if you've replace all occurrences of the matched
> text nothing will be left highlighted and you won't have to :set
> nohlsearch.
>
> > I always thought that '<,'> already say: Do that only inside
> > the visual block.
> > Why do I need to specify \%V additionally.
> > Or do I get all this totally wrong ??????
> >
> > By the way: I treid to find the expression \%V inside the vim
> > help...but didnt foudn a match. What is the correct
> > keyword to find the according help?
> >
> > Best regards,
> > mcc
> >
> >
> >
> > --
> > --
> > You received this message from the "vim_use" 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_use" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> --
> You received this message from the "vim_use" 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_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment