Tuesday, April 1, 2014

Re: "local hlsearch"


On Apr 1, 2014 9: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.
>
> I always thought that '<,'> already say: Do that only inside
> the visual block.

First of all, this means "do that only inside a range of visual selected *lines*". Makes difference for block- and character-wise selections.

Second, this specifies a range, not limits operational area in any fashion. You can easily construct a :s command that operates outside of this range: using multiline matches only *start* of the match is required to be inside the range (and with \zs (but not with lookbehinds) start of the match *operated upon* is not required to be inside this range).

Third, this specifies a range *for one normal-mode command*. Search highlighting is a different entity and it does not and should not respect this range. Though I would be happy if there was a flag for :s to not modify search history, search highlighting and current search pattern.

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

No comments:

Post a Comment